4.4.22 · D3Databases

Worked examples — Denormalization — when and why

3,480 words16 min readBack to topic

The one tool we lean on is the parent's boxed rule. Let us re-earn every symbol before using it.

The rule is a boundary line — see it first

The inequality is not just algebra: it carves a plane into two regions. Put the traffic ratio on the horizontal axis and the cost ratio on the vertical axis. The rule fires whenever — i.e. below the diagonal line . Every one of our matrix cells is just a dot placed somewhere on this plane; the diagonal decides its fate.

Look at the figure: the pale-yellow diagonal is the break-even line (). The blue region below-right is "denormalize" (); the pink region above-left is "stay normalized" (). Cell A sits deep in the blue (read-heavy); Cell B sits in the pink (write-heavy); Cell C rides exactly on the yellow line. Keep this picture in mind — every example below is just locating its dot.


The scenario matrix

Every situation this topic throws lands in one of these cells. The examples below fill each row. The Region column tells you which side of the diagonal (from the figure above) the cell lands on.

Cell Meaning What makes it tricky Region Example
A. Read-heavy Obvious win — but prove it blue () Ex 1
B. Write-heavy Denormalizing loses pink () Ex 2
C. Break-even exactly The knife-edge; tie-break applies on line Ex 3
D. Zero-write limit Rule always says "yes" — why? far-right blue Ex 4
E. Zero-join-cost degenerate Rule can never say yes pink Ex 5
F. Aggregate scaling cost grows with read vs write blue, deepening Ex 6
I. Zero-read limit Nothing to speed up — always "no" far-left pink Ex 7
G. Real-world word problem plug real numbers translate English → symbols blue Ex 8
H. Exam twist hidden write amplification one edit fans out to many syncs blue → pink Ex 9

The sign-chart below is the same plane again, but now with each lettered cell pinned to its spot so you can see the cases as one gestalt rather than a list of facts.

Notice how D pushes right to the edge (huge ), E floats up off the top (infinite ), I hugs the left edge (tiny ), and H starts blue but slides toward pink as its hidden write cost grows — that migration is the whole trick of Ex 9.


Worked examples

The next figure zooms into this example: as we sweep along the x-axis, slides down through zero at exactly — the same crossing the diagonal represented globally.

Read the figure: left of the pink dashed line () is above zero (blue, denormalize); right of it dips negative (pink, don't); the yellow dot is the knife-edge itself.

The figure below shows why this is inevitable: the normalized read cost climbs as a straight line in , while the sync write cost stays flat — the growing gap between them is the saving.

Look at the shaded pink gap: it widens with , which is the visual meaning of " read beats write."


Recall

Recall Which matrix cells forbid the ratio form, and why?

Cell E () makes divide by zero. Use instead — it is defined everywhere. Answer ::: always compute near degenerate/limit inputs. At an exact break-even () which schema wins? ::: The normalized one — the tie-break rule sends ties to the simpler design because redundancy carries an unpriced drift risk. What happens in the zero-read limit ()? ::: The saving term vanishes, becomes negative — never denormalize; nothing to speed up. What is "write amplification" (Ex 9)? ::: One logical write fanning out to many physical row updates, inflating the true far above the per-row cost. On the boundary plane, where is "denormalize"? ::: Below-right of the diagonal , i.e. where traffic ratio exceeds cost ratio .


Connections

  • ← Back to parent: Denormalization — when and why
  • Materialized Views — the natural home for Cell D (read-only, denormalize by default)
  • Database Triggers — the guard used in Ex 8 to enforce the duplicated count
  • Update Insert Delete Anomalies — the drift risk that breaks break-even ties
  • Indexing — often shrinks (pushes you back toward Cell E) without any duplication
  • OLTP vs OLAP — OLTP tends to Cell B, OLAP to Cell D
  • Normalization (1NF 2NF 3NF BCNF) — the baseline every example starts from
Which decision form is safe at degenerate/limit inputs?
The form, because it never divides by zero.
Why does denormalization still lose when ?
There is no read cost to save, so any positive makes negative regardless of read volume.
Why does denormalization lose when ?
The saving term vanishes; only write cost remains, so — nothing to speed up.
What is the tie-break rule when ?
Prefer the normalized schema; ties go to the simpler design because redundancy carries an unpriced drift risk.
As comment count grows, why does denormalizing comment_count win harder?
Normalized read cost is while the sync write is ; the read saving grows with .
What is write amplification and why does it matter to ?
One logical write updating many duplicated rows; is total per-write work, so amplification can flip a "yes" to a "no".
On the decision plane, what line separates denormalize from stay-normalized?
The diagonal (traffic ratio equals cost ratio), which is exactly the break-even .