Skip to content
← Notes

Data Modeling

Entities, normalization, schema evolution

  1. 00 Data Modeling — Roadmap Ten chapters that take you from 'what's a primary key' to deliberate schema design under load — keys, normalization, denormalization, constraints, multi-tenancy, JSONB, and zero-downtime evolution.
  2. 01 What data modeling is Schema design is the most expensive thing you ship. The columns you pick on day one outlast every framework, every refactor, every rewrite. Modeling well is mostly thinking before typing CREATE TABLE.
  3. 02 Entities, attributes, relationships Before SQL, before ORMs, draw the boxes and lines. ER thinking is twenty minutes that saves a year of refactoring.
  4. 03 Keys The primary key is the most expensive choice in your schema. Pick wrong and you spend years working around it. Pick right and you forget it exists.
  5. 04 Normalization 1NF, 2NF, 3NF — three rules that prevent the same data from being recorded twice. Ignore them and your schema rots from the inside as data drifts out of sync.
  6. 05 Denormalization Sometimes the same fact lives in two places on purpose. Done well, it makes hot queries fly. Done badly, it creates the exact drift normalization was designed to prevent.
  7. 06 Constraints The schema is your last line of defense against application bugs. Constraints encode the rules that should always be true — Postgres enforces them whether your app remembers to or not.
  8. 07 Time and soft delete Timestamps that survive time zones, soft delete that doesn't poison every query, and history tables that answer 'what did this look like last Tuesday?'
  9. 08 Multi-tenancy Three architectures for serving many customers from one app: single database with a tenant column, schema per tenant, or a database per tenant. Each has a different cost curve.
  10. 09 JSONB and the schemaless trap JSONB is one of Postgres's best features. Used well, it's how you stop fighting your schema. Used badly, it's how you end up with a schemaless mess inside a relational database.
  11. 10 Schema evolution Every schema change against live data is a deploy. The expand/contract pattern is how you change tables that have a million rows and a thousand concurrent writers without downtime.