Writing Portable SQL
How much portability is worth paying for, which constructs are safe everywhere, and how to isolate the parts that can never be portable.
Designing schemas, entities and relationships.
11 notes tagged
How much portability is worth paying for, which constructs are safe everywhere, and how to isolate the parts that can never be portable.
Storing and querying trees: the adjacency list, walking it with a recursive CTE, and the materialised path and closure table alternatives.
The three anomalies normalisation prevents, and the disciplined way to reintroduce redundancy when reads genuinely demand it.
The formal notation behind normalisation, and the stricter normal form that catches what 3NF allows through when candidate keys overlap.
Normalisation worked through on one table: remove repeating groups, then partial dependencies, then transitive ones - with the SQL at each step.
The three kinds of integrity a relational database enforces, why redundancy causes anomalies, and where a derived value is worth its maintenance cost.
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...
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...
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.
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 vocabulary of keys, explained on one table: which columns could identify a row, which one you choose, and what happens to the rest.