Recursive CTEs
Query a hierarchy of unknown depth, generate a series of rows, or follow a chain of references - all with one self referencing CTE.
963 published notes across every category.
Query a hierarchy of unknown depth, generate a series of rows, or follow a chain of references - all with one self referencing CTE.
The four constraints that guard a single table. What each one enforces, how NULL interacts with UNIQUE and CHECK, and why the database is the right pl...
The two constraints that give a database its structure: one that identifies a row, and one that guarantees a reference points at something real.
What happens to child rows when a parent is deleted or updated, how to choose between RESTRICT, CASCADE and SET NULL, and how to add, drop and disable...
The vocabulary of keys, explained on one table: which columns could identify a row, which one you choose, and what happens to the rest.
Should the primary key come from the data or be generated? The trade offs, the failure modes of each, and the pattern most teams settle on.
The two simplest relationships and the single rule that decides where the foreign key goes - plus when a one to one split is actually worth it.
Two tables that both have many of each other need a third table. Learn the junction table pattern, its key design, and how to query and count across i...
How to get from a description of a business to a set of tables: find the entities, give them attributes, connect them, and name everything consistentl...
The three kinds of integrity a relational database enforces, why redundancy causes anomalies, and where a derived value is worth its maintenance cost.
Normalisation worked through on one table: remove repeating groups, then partial dependencies, then transitive ones - with the SQL at each step.
The formal notation behind normalisation, and the stricter normal form that catches what 3NF allows through when candidate keys overlap.