Denormalization

In traditional database design (RDBMS), we focus on Normalization. We split data into multiple tables to avoid duplication and ensure data integrity.

However, as systems scale, Joins become expensive and slow.

Denormalization is the process of intentionally adding redundant data to a database to speed up read operations.


Why Denormalize?


Example: Social Media Post

Normalized (Pure SQL)

To show a feed, you must JOIN Posts with Users for every single post to get the author's name and avatar.

Denormalized

Now, you can show the feed by querying only the Posts table. No joins required.


The Trade-off (The Data Integrity Cost)

Denormalization is not "free". You pay for it with:

  1. Storage Space: You are storing the same data (user name) in thousands of post records.
  2. Write Complexity: If a user changes their name, you must update it in the Users table AND all their Posts records.
  3. Inconsistency: If the update fails halfway, some posts will show the old name and some the new name (Eventual Consistency).

When to Use It?


Key Takeaways

Don't be afraid of duplicating data. At scale, disk space is cheap, but user waiting time is expensive.