Reason correctly about NULL in SQL
8 steps · about 2 h 25 min · Intermediate
- Distinguish SQL NULL from a value (reference, PostgreSQL Global Development Group, 10 min)
Sets the type context before exploring why NULL is not an empty string, zero or ordinary sentinel.
- Use NULL-aware comparisons (guide, PostgreSQL Global Development Group, 20 min)
Documents IS NULL, IS DISTINCT FROM and the unknown results produced by ordinary comparison.
- Trace three-valued logic (guide, PostgreSQL Global Development Group, 15 min)
Truth tables make AND, OR and NOT behavior predictable when one input is unknown.
- Choose COALESCE and CASE deliberately (guide, PostgreSQL Global Development Group, 20 min)
Shows when to substitute a display value and when preserving missingness is the more honest choice.
- Check how aggregates treat NULL (guide, PostgreSQL Global Development Group, 20 min)
Highlights the important difference between COUNT(*) and COUNT(column) and how missing inputs affect results.
- Understand NULL in constraints (reference, PostgreSQL Global Development Group, 25 min)
Explains not-null, unique, check and foreign-key clauses so missing values are constrained intentionally.
- Connect unknown logic across clauses (guide, Modern SQL, 20 min)
Brings filters, joins and constraints together around one consistent three-valued model.
- Practise a NULL-aware filter (interactive, PostgreSQL Exercises, 15 min)
A small PostgreSQL exercise gives immediate feedback on selecting rows whose value is missing.