Normalization vs Denormalization
Normalize to reduce duplication; denormalize to avoid expensive joins at scale.
A seller changes their shop name. Your database updates one row, and every page showing that name is instantly correct, because every one of them reads it from that row.
That is normalisation: each fact stored exactly once. It also means the page showing an order has to join four tables to show a name, a product, a price and a city.
At 50 requests a second those joins cost nothing. At 5,000 they are most of what your database does, and somebody proposes copying the seller's name onto the order row.
Do that and reads get fast and the shop name now lives in two places, so the next rename has to find both. Neither choice is a virtue. They are opposite ends of one dial, and which way it should turn changes over the life of a product.
Lessons
3 in this chapter- Normal Forms in PracticeOne fact, one place. That sentence is 90 percent of normalization.3 min
- Why Reads Push You to DenormalizeJoins are cheap until traffic, data size, or sharding makes them the bottleneck.3 min
- Keeping Duplicates HonestThe moment a fact lives in two places, you own the job of keeping them in agreement.3 min