20 May 2024
20 May 2024

The CHECK() Constraint

One of the many ways a relational table differs from the file structures used by pre-relational storage systems is that the tables, rows and columns can have constraints on them. This allows you to reduce the types of bad data that can be loaded into your tables. This lets the database do a lot of … Read more
17 April 2024
17 April 2024

Database Subsetting and Data Extraction

Let’s start by defining a subset and why you would require a data subset? When dealing with the development, testing and releasing of new versions of an existing production database, developers like to use their existing production data. In doing so, the development team will be hit with the difficulties of managing and accommodating the … Read more
29 March 2024
29 March 2024

SQL Logic

In this article, I will discuss the history and thinking behind several types of logic that are typically associated with writing relational database code. Because of how relational databases implement NULLs, it definitely can make some processes more complex than expected by may programmers (inexperienced and experienced alike!) Three Valued Logic Missing or UNKNOWN values … Read more
18 March 2024
18 March 2024

Department of Redundancy Department

Ever wonder all the reasons that we use databases instead of file systems? While we don’t think of it too much anymore, the first reason that databases came into existence was to remove redundancies. The first source of redundancy back in the dark ages, when I was just beginning the program, was a product called … Read more
02 January 2024
02 January 2024

Two-Dimensional Interval Packing Challenge

Packing intervals is a classic SQL task that involves packing groups of intersecting intervals to their respective continuous intervals. In mathematics, an interval is the subset of all values of a given type, e.g., integer numbers, between some low value and some high value. In databases, intervals can manifest as date and time intervals representing … Read more
18 December 2023
18 December 2023

Using a SQL Tokenizer

Imagine this: you have several directories full of SQL script files, and you need to know where a certain table is used. You’d rather like the context too, so you can check the whole SQL Expression and work out why it is running so slowly. Maybe, from that same daunting set of several directories, you … Read more
09 November 2023
09 November 2023

The NTILE Function

The SQL NTILE() is a window function that allows you to break a table into a specified number of approximately equal groups, or <bucket count>. For each row in a grouping, the NTILE() function assigns a bucket number representing the group to which the row belong starting at one. The syntax of the NTILE() function … Read more
05 October 2023
05 October 2023

First Normal Form Gets No Respect

Dr. Codd first described the relational model in a paper in Communications of the ACM (CACM 13 No 6; June 1970). Some more work followed up after that by other people, giving us normal forms and other things we have taken for granted for 50+ years.  I was looking at some postings on a SQL … Read more
10 July 2023
10 July 2023

The GROUP BY Clause

When you’re learning SQL DML, the most complicated clause is typically the GROUP BY. It’s a fairly simple grouping based on values from the FROM clause in a SELECT statement. It’s what a mathematician would call an equivalence relation. This means that each grouping, or equivalence class, has the same value for a given characteristic … Read more
14 April 2020
14 April 2020

Codd’s Twelve Rules

Dr. Codd proposed the normalization rules we used to design databases, but did you know that he also came up with rules that vendors must meet to call their products relational database systems? In this article, Joe Celko explains the thirteen RDBMS rules.… Read more