Course map
Stage 1: Foundation
Stage 2: Intermediate
Stage 3: Advanced
Stage 4: Performance & internals
Stage 5: Specialization

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_price in shopdb duplicates products.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_value column 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.

  1. Why is order_items.unit_price not a normalization mistake?
  2. What obligation does every denormalized column carry?
Show the answers
  1. 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.
  2. 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.

Search the guide