Part 09 / Topic 6 of 7
When to denormalize
Normalization optimises for correct writes; sometimes you need fast reads. Denormalizing — copying a fact to where it is read — is legitimate when you can say the trade out loud:
order_items.unit_pricein shopdb duplicatesproducts.price— deliberately. It is the price as sold; the product's price changes later, history must not. (Strictly that's a different fact, which is why it's the classic "good duplication".)- A
customers.lifetime_valuecolumn spares recomputing the Part 6 CTE on every page view — and is now a cached value that must be refreshed when orders change. - A reporting table rebuilt nightly (Part 13's materialized views do this properly).
The honest framing: denormalization converts a read cost into a consistency obligation. Take it when reads are hot and the refresh path is owned — never "to keep things simple". Normalize first, measure, then denormalize the specific pain.
🧪 Quick quiz — answer from memory, then check.
- Why is
order_items.unit_pricenot a normalization mistake? - What obligation does every denormalized column carry?
Show the answers
- It records the price at sale time — a historical fact that must survive later price changes; products.price is the current price, a different fact.
- Someone must keep it consistent when the source changes — a refresh path, owned and tested.
Done here? The practice set for Part 9 — 4 exercises with solutions — is on the part page.