1. ID Auto-increment
- Auto-increment
- UUID v4: do not use for b-tree
- UUID v7: use prefix timestamp
2. Contraints in DB
- NOT NULL — the cheapest correctness win available. Nullable columns force every consumer to handle null, and half of them will not.
- UNIQUE — enforces uniqueness and creates an index. Note that in PostgreSQL, NULL values do not conflict — multiple rows can have NULL in a unique column.
- FOREIGN KEY — prevents orphans. Choose ON DELETE behaviour deliberately: RESTRICT (default, safe), CASCADE (convenient, occasionally catastrophic), SET NULL.
- CHECK — arbitrary boolean conditions. CHECK (amount_cents >= 0), CHECK (status IN (...)), CHECK (ends_at > starts_at).
- EXCLUDE — PostgreSQL-specific, underused, and impressive when mentioned appropriately. Prevents overlapping ranges — exactly what a booking system needs:
3. Normalization
- Denormalization:
- A hot join
- Cross-shard join impossible
- A hot read.
- Historical data
- Normalization


4. Transactional
5. Question (Normalize, Denormalize)
🟡 "How would you decide between normalising and denormalising?"