Part 2 of 5 · 1 min read
What denormalization actually is
Deliberately storing a duplicate or precomputed value, to avoid a join or a repeated calculation.
Think of writing today's exchange rate on every single invoice for the day. That beats looking it up fresh from a central source every time an invoice is read.
In plain words: denormalization means deliberately storing some redundant or precomputed data, to avoid an expensive join or recalculation on every read. It is the opposite of normalization's "store each fact exactly once," chosen on purpose for a specific, measured reason.
A worked example. Storing a book's author_name directly on an order_items row, alongside the normal book_id reference, avoids a join to books and then to authors every single time an order's receipt is displayed.
The key lines.
-- normalized: requires a join to show the author's name on a receipt
SELECT oi.quantity, b.title, a.name
FROM order_items oi JOIN books b ON oi.book_id = b.book_id JOIN authors a ON b.author_id = a.author_id;
-- denormalized: author_name stored directly, no join needed to display it
order_items (order_id, book_id, quantity, author_name_snapshot)
Denormalization
Denormalization is deliberately storing redundant or precomputed data to avoid an expensive join or recalculation on every read, accepted knowingly as a trade-off.
Example: author_name_snapshot on order_items avoids a two-table join every time a receipt is displayed, at the cost of storing the author's name redundantly.