Database.What is Denormalization?

Denormalization is the process of intentionally adding redundancy into a database — basically undoing some of the normalization — in order to improve read performance.

Key Idea:

  • In normalization, we split data into multiple related tables to reduce redundancy.
  • In denormalization, we combine tables or add redundant columns to make reads faster (at the cost of some redundancy).

Why Denormalize?

  1. Performance:
    • Complex queries in a fully normalized database might require multiple JOIN operations.
    • Joins are expensive — they cost time and resources.
    • Denormalization can speed up queries by reducing or eliminating joins.
  2. Simpler Queries:
    • Fewer joins mean easier, faster queries.
  3. Precomputed Data:
    • Sometimes, denormalization involves storing computed values like totals, counts, or derived data to avoid recalculating them.

Example

Normalized Tables (good design, normalized to 3NF):

Customers

customer_idcustomer_name
1Alice
2Bob

Orders

order_idcustomer_idorder_date
10112025-06-01
10222025-06-02

To get the customer’s name with the order:

SELECT o.order_id, c.customer_name, o.order_date
FROM Orders o
JOIN Customers c ON o.customer_id = c.customer_id;

Denormalized Table:

order_idcustomer_idcustomer_nameorder_date
1011Alice2025-06-01
1022Bob2025-06-02

Now:

  • customer_name is stored redundantly in the Orders table.
  • No JOIN needed to fetch the customer name!

But:

  • If Bob changes his name, you have to update it everywhere Bob’s name appears — risk of inconsistency.

Advantages vs Disadvantages

AdvantagesDisadvantages
Faster reads (less joins).Redundancy — same data in many places.
Simpler queries (fewer joins to write).Harder to update — more maintenance.
Precomputed values can improve speed.Risk of inconsistencies.
Better for reporting, analytics systems.More storage space used.

In Simple Words:

  • Normalization = Break apart to avoid redundancy. Good for updates and data consistency.
  • Denormalization = Copy data around to make reads faster. Good for performance and speed.

In Simple Words:

  • Normalization = Break apart to avoid redundancy. Good for updates and data consistency.
  • Denormalization = Copy data around to make reads faster. Good for performance and speed.

Real-World Analogy

  • Normalized: You have one file cabinet for customers, another for orders — to find a customer’s order, you cross-reference both.
  • Denormalized: You make a folder for each order and also write the customer name on each one — easier to find, but if the customer changes their name, you have to update every folder manually!
This entry was posted in Без рубрики. Bookmark the permalink.