Relational foundations
Syllabus
Detailed content
Tables, rows, and relationships
A relational database stores data in tables whose rows represent records and whose columns have defined types. Primary keys identify rows; foreign keys enforce relationships. Constraints protect invariants even when data is written by multiple applications. Start by naming the entities and relationships in the domain.
SQL query structure
A SELECT query describes columns, source tables, filters, grouping, and ordering. SQL is declarative: it says what result is wanted, while the database chooses how to produce it. Use explicit column names, parameterized values, and bounded result sets. Understand that NULL represents unknown or missing information and changes comparison behavior.
Insert, update, delete, and constraints
INSERT creates rows, UPDATE changes matching rows, and DELETE removes them. Always inspect the filter on a mutation and use transactions for multi-step changes. NOT NULL, UNIQUE, CHECK, and foreign-key constraints reject invalid states at the database boundary, protecting correctness across all application code paths.