Data modeling
For engineers
Designing schemas with keys and constraints, normalizing on purpose, and changing schemas safely with migrations an agent may write
110 questions across four stages: Understand, Apply, Solve and Judge.
Try 5 questions
Practice items, not counted towards your mastery. No account needed.
Check yourself · 1 of 5
What turns a column named customer_id into an enforced relationship?
Check yourself · 2 of 5
A table stores customer_email on every order row. What problem does this create?
Check yourself · 3 of 5
What is the first step when replacing a column that the running app reads?
Check yourself · 4 of 5
A generated table has a column role_ids text holding values like '1,4,9'. What is the fix?
Check yourself · 5 of 5
In a shared table for many customers, which UNIQUE constraint fits a contact's email?
Topics
- Designing tables from a domain5 min read · Turning entities and relationships into tables with primary keys, foreign keys, NOT NULL, CHECK and unique constraints that make bad rows impossible
- Normalizing and deliberate denormalization5 min read · Normal forms in plain terms, update anomalies, and copying data for read speed only with a rule that keeps the copies in sync
- Zero-downtime schema migrations6 min read · Expand and contract steps, batched backfills, adding columns and indexes without long locks, and migrations that can be rolled back
- Schema anti-patterns in generated models5 min read · Entity-attribute-value tables, comma lists in one column, money stored as floats, missing foreign keys and timestamps without time zones in AI scaffolds
- Modeling tenants, history and soft deletes6 min read · Tenant ids on every row, row-level security, audit and history tables, and soft-delete flags that every query must remember
Start here
- PostgreSQL: Data definition (opens in a new tab)DocsFree
How tables, constraints, row security and schema changes are declared in PostgreSQL.
- PostgreSQL: Constraints (opens in a new tab)DocsFree
Exact behaviour of CHECK, NOT NULL, UNIQUE, primary and foreign keys and their ON DELETE actions.
- PostgreSQL: ALTER TABLE (opens in a new tab)DocsFree
Which ALTER TABLE forms rewrite the table or take strong locks, and the NOT VALID option.
Scenarios
Helps to know first
110 questions · last verified 2026-12