Foundations
Foundations
The half-dozen ideas every later SQL chapter assumes — what SQL is, the logical order it runs your clauses in, projection, filtering, ordering, and how rows get into the table in the first place.
Suggest an editFoundations
Before any join, aggregate, or window function makes sense, six things have to be in place: what SQL is (a declarative query language, not a procedural one), the logical order in which a SELECT actually runs (FROM → WHERE → GROUP BY → HAVING → SELECT → DISTINCT → ORDER BY → LIMIT — not the order you write them), how to project columns, how to filter rows (and the NULL trap that catches every junior engineer at least once), how to sort and paginate (and why LIMIT/OFFSET falls over at scale), and how to define and modify the data in the first place.
This module covers all six. Every later chapter in the SQL section leans on the vocabulary built here — so if you skip it, you'll find yourself bluffing through query plans for the rest of your career.
Place in the curriculum
- Prerequisites: none. Basic programming literacy is enough; no prior SQL experience assumed.
- Followed by: every other module. The Introduction chapter especially is cited by every join, aggregate, and window-function chapter.
Chapters
- Introduction to SQL — what SQL is, declarative vs imperative, the logical execution order that every SQL question hinges on, dialect map, the sample schema used across the rest of the book.
- SELECT and Projection — column expressions, aliases,
DISTINCT, the alias-namespace trap, computed columns. - Filtering —
WHERE, predicates,BETWEEN/IN/LIKE, and the NULL trap that breaks intuitive boolean logic. - Ordering and Pagination —
ORDER BY,NULLS FIRST/LAST, theLIMIT/OFFSETtax, keyset pagination as the production answer. - Data Definition —
CREATE/ALTER/DROP TABLE, types, constraints (an introduction; deep treatment in module 7). - Data Manipulation —
INSERT/UPDATE/DELETE,RETURNING,ON CONFLICT, the basic transactional shape (deep treatment in module 9).