AI Hints
Home›System Design Tutorial›Storing More Kinds of Data
System Design · Lesson 49 of 120

Denormalization

Copies for speed.

⏱ 2 min read▶ Video at 57:52🎓 Free
Watch this lesson in the System Design courseWatch on YouTube ↗Full System Design course

In a classic relational design, every fact is stored once. Customer names live only in the customers table. That's called normalized. But sometimes, storing a copy makes reads much faster. That's denormalization.

Denormalization
From the video: Denormalization
  • Every fact stored once
  • That's normalized
  • Copies for speed

Two ways to show an order

To show an order with the customer's name, a normalized design joins the orders table with the customers table on every read. A denormalized design copies the name into the order row, so one read is enough. Reads get faster. But if the customer changes their name, every copy must be updated.

Normalized

  • Each fact onceJoins on every readEasy updates

Denormalized

  • Copies of factsNo joins, fast readsUpdates touch many rows

When to denormalize

Denormalize when reads vastly outnumber writes, and when joins have become a real bottleneck. It's especially common with No SQL databases and shards, where joins are hard. Keep the original as the source of truth, and treat the copies as caches you can rebuild.

keyvalue
Reads ≫ writescopies pay off
Joins too slowmeasured, not guessed
Shards, NoSQLjoins are hard
Source of truthkeep one original

Summary

Denormalization stores copies of data to avoid slow joins, at the cost of harder updates. Use it when reads dominate. Next, where to keep big files, like photos and videos.

Key takeaways
  • Normalized: once
  • Denormalized: copies
  • Faster reads, harder writes
Next up: Object Storage — files and photos