SQL Interview: Normalisation, NULL and Query Optimisation
Design and correctness questions: the normal forms, why NULL breaks intuition, and how to answer "this query is slow, what do you do?"
NULL, unknown values and three valued logic.
10 notes tagged
Design and correctness questions: the normal forms, why NULL breaks intuition, and how to answer "this query is slow, what do you do?"
Subqueries that reference the outer row and run once per row. Learn EXISTS and NOT EXISTS, why they are NULL safe, and when correlation costs too much...
Subqueries that return a list of values, and the three operators that consume them - including the NULL trap that makes NOT IN return nothing.
Outer joins keep unmatched rows and fill the missing side with NULL. Learn LEFT and RIGHT JOIN, and the one mistake that silently turns an outer join...
The five aggregate functions that collapse many rows into one value, the three forms of COUNT, and what each one does with NULL.
SQL conditions return three results, not two. Learn the AND, OR and NOT truth tables, why NOT IN breaks on NULL, and the NULL safe comparison operator...
NULL is not zero, not an empty string and not equal to itself. Learn what it represents, how it spreads through expressions and how to handle it delib...
Conditional logic inside a query, NULL substitution, safe division and explicit type conversion - four tools that remove most procedural code from SQL...
The four filtering shortcuts you will use constantly: set membership, ranges, pattern matching with wildcards, and the only correct way to test for NU...
Combining conditions correctly. Precedence between AND and OR, what NOT does to a NULL, and how to keep complex filters readable and index friendly.