Copy data on purpose to avoid slow joins, and pay for it with extra writes.
Denormalization means storing the same piece of data in more than one place on purpose, so reads need fewer joins. Reads get faster and simpler. Writes get heavier and riskier.
Good relational design is normalized: each fact lives in exactly one table. A customer's name is in the customers table, and orders only hold a customer_id. To show an order with the name, the database does a join. Joins are fine on small data. On huge data, or across shards, they get slow or impossible.
The idea is simple: do the work at write time instead of read time. You pay a little extra each time you write, so that each read is cheap.
| Pattern | Example | Cost |
|---|---|---|
| Copy a column | Put customer_name into orders. | Update all copies if the name changes. |
| Precomputed aggregate | posts.comment_count, orders.total. | Update the number on every insert or delete. Races are possible. |
| Embed child rows | Store order items as a JSON array in the order (or a document). | Large documents. Hard to query items alone. |
| Pre-joined table | A wide reporting table built from several tables. | Must be rebuilt or kept in sync. |
| Summary table | daily_sales (date, total) built from orders. | Refreshed by a job or trigger. |
| Materialized view | The database keeps and refreshes a stored query result. | Storage and refresh cost (see Materialized Views). |
| Snapshot of history | Copy the price into the order line at purchase time. | None really. This is often correct, not a bug. |
A simplified cost model in abstract units with a simulated, deterministic data set (no random numbers). Real costs depend on indexes, cache hits and row size. The shape is what matters: denormalization trades cheaper, simpler reads for more expensive and riskier writes.
SET count = count + 1), and a repair job that recounts now and then.| Term | Meaning in easy words |
|---|---|
| Normalization | Designing tables so each fact is stored once |
| Denormalization | Copying data on purpose to speed up reads |
| Join | Combining rows from two tables using a shared key |
| Source of truth | The one place whose value is correct |
| Update anomaly | Copies disagree because some were not updated |
| Derived data | Data computed or copied from other data |
| Read:write ratio | How many reads happen for each write |
| Write amplification | One logical change causing many physical writes |
| Embedding | Storing child data inside the parent record or document |
| Change data capture (CDC) | A stream of every change in a database, used to update copies |
| Star schema | A warehouse design: one wide facts table surrounded by small dimension tables |
| Choice | We gain | We lose |
|---|---|---|
| Copy data into the read table | No join on read | Update work and anomaly risk |
| Store a counter | O(1) count | Race conditions, drift |
| Sync in the same transaction | Copies always agree | Slower, more locks, same database only |
| Sync with events | Scales, decoupled | Eventual consistency, extra moving parts |
| Rebuild nightly | Simple | Data is up to a day old |
| Stay normalized | Clean and safe | Joins may become the bottleneck |