Bird
Raised Fist0
HLDsystem_design~10 mins

Database normalization vs denormalization in HLD - Scaling Approaches Compared

Choose your learning style10 modes available
Scalability Analysis - Database normalization vs denormalization
Growth Table: Database Normalization vs Denormalization
Users / Data SizeNormalized DBDenormalized DB
100 usersSimple joins, low redundancy, easy updatesFast reads, some data duplication, simple queries
10,000 usersMore joins, moderate query complexity, good data integrityFaster read queries, larger storage, update complexity grows
1 million usersJoins become expensive, slower queries, DB CPU load risesRead-heavy workloads scale well, write/update latency increases
100 million usersJoins cause major slowdowns, DB scaling hard without shardingMassive storage needs, complex update logic, caching essential
First Bottleneck

In a normalized database, the first bottleneck is the join operations on large tables. As data grows, joins consume CPU and slow queries.

In a denormalized database, the bottleneck is write/update operations. Because data is duplicated, updates must modify multiple places, increasing latency and risk of inconsistency.

Scaling Solutions
  • Normalized DB: Use read replicas to offload read queries, add indexes, and consider sharding large tables to reduce join costs.
  • Denormalized DB: Use caching layers (like Redis) to speed reads, implement batch updates to reduce write overhead, and use event-driven mechanisms to keep data consistent.
  • For both, horizontal scaling of database servers and application servers helps handle increased load.
  • Use CDNs for static content to reduce database load indirectly.
Back-of-Envelope Cost Analysis

Assuming 1 million users with 10 requests per second (RPS):

  • Normalized DB: 10 RPS with complex joins may require multiple read replicas (5-10) to handle CPU load.
  • Denormalized DB: 10 RPS mostly reads, but writes may be slower due to duplication; write throughput may need batching.
  • Storage: Denormalized DB uses 20-50% more storage due to duplicated data.
  • Bandwidth: Both require similar network bandwidth; denormalized may send more data per query.
Interview Tip

Start by explaining the trade-offs: normalization improves data integrity and reduces storage but can slow reads due to joins. Denormalization speeds up reads but complicates writes and increases storage.

Discuss workload patterns (read-heavy vs write-heavy) to decide which approach fits best.

Outline scaling strategies for each and mention how caching and sharding help.

Self Check

Your database handles 1000 QPS. Traffic grows 10x to 10,000 QPS. What do you do first?

Answer: Identify if the bottleneck is read or write. For normalized DB, add read replicas and optimize indexes to handle more reads. For denormalized DB, implement caching and batch updates to reduce write load.

Key Result
Normalized databases face join-related CPU bottlenecks as data grows, while denormalized databases face write/update complexity and storage overhead. Scaling requires read replicas and sharding for normalized DBs, and caching plus batch updates for denormalized DBs.

Practice

(1/5)
1. What is the main goal of database normalization?
easy
A. To reduce data duplication and improve data accuracy
B. To combine tables for faster data retrieval
C. To increase storage space usage
D. To make queries more complex

Solution

  1. Step 1: Understand normalization purpose

    Normalization organizes data to minimize duplication and maintain consistency.
  2. Step 2: Compare with other options

    Combining tables and increasing storage are characteristics of denormalization, not normalization.
  3. Final Answer:

    To reduce data duplication and improve data accuracy -> Option A
  4. Quick Check:

    Normalization = reduce duplication [OK]
Hint: Normalization means less duplication, more accuracy [OK]
Common Mistakes:
  • Confusing normalization with denormalization
  • Thinking normalization increases storage
  • Believing normalization makes queries faster
2. Which of the following is a correct statement about denormalization?
easy
A. It always reduces data redundancy
B. It combines tables to speed up read queries
C. It enforces strict data integrity rules
D. It splits data into many small tables

Solution

  1. Step 1: Identify denormalization effect

    Denormalization merges tables to reduce joins and speed up reads.
  2. Step 2: Eliminate incorrect options

    Reducing redundancy and splitting tables are normalization traits; strict integrity is also normalization.
  3. Final Answer:

    It combines tables to speed up read queries -> Option B
  4. Quick Check:

    Denormalization = combine tables for speed [OK]
Hint: Denormalization speeds reads by merging tables [OK]
Common Mistakes:
  • Mixing up normalization and denormalization goals
  • Assuming denormalization reduces redundancy
  • Thinking denormalization splits tables
3. Consider a database where customer and order data are stored in separate tables (normalized). If we denormalize by combining them into one table, what is the likely effect on query performance?
medium
A. Write queries become faster, read queries become slower
B. Both read and write queries become slower
C. No change in query performance
D. Read queries become faster, write queries may slow down

Solution

  1. Step 1: Analyze denormalization impact on reads

    Combining tables reduces joins, so read queries speed up.
  2. Step 2: Analyze impact on writes

    More data in one table means writes may take longer due to larger rows and possible duplication.
  3. Final Answer:

    Read queries become faster, write queries may slow down -> Option D
  4. Quick Check:

    Denormalization = faster reads, slower writes [OK]
Hint: Denormalize to speed reads, but writes may slow [OK]
Common Mistakes:
  • Assuming writes always get faster
  • Ignoring join cost in normalized reads
  • Believing no performance change occurs
4. A developer denormalized a database by duplicating user address data in multiple tables but forgot to update all copies when the address changed. What problem does this cause?
medium
A. Data inconsistency due to redundant copies
B. Faster query performance without side effects
C. Reduced storage space usage
D. Improved data integrity

Solution

  1. Step 1: Understand denormalization risk

    Duplicating data can cause inconsistencies if updates are not synchronized.
  2. Step 2: Evaluate consequences

    Failing to update all copies leads to conflicting data, harming accuracy.
  3. Final Answer:

    Data inconsistency due to redundant copies -> Option A
  4. Quick Check:

    Denormalization risk = inconsistency if not managed [OK]
Hint: Duplicated data needs careful updates to avoid inconsistency [OK]
Common Mistakes:
  • Assuming denormalization always improves integrity
  • Ignoring update complexity in denormalized data
  • Thinking denormalization reduces storage
5. You are designing a high-traffic e-commerce system. You want to optimize for fast product search and order history retrieval. Which approach balances normalization and denormalization best?
hard
A. Normalize all data strictly to avoid any duplication
B. Normalize product data and denormalize order history
C. Denormalize product data for fast search, normalize order history for accuracy
D. Denormalize all tables to speed up all queries

Solution

  1. Step 1: Identify system needs

    Fast product search benefits from denormalization to reduce joins and speed reads.
  2. Step 2: Consider order history requirements

    Order history needs accuracy and consistency, so normalization is better.
  3. Step 3: Choose balanced approach

    Denormalize product data for speed, normalize order data for integrity.
  4. Final Answer:

    Denormalize product data for fast search, normalize order history for accuracy -> Option C
  5. Quick Check:

    Balance = denormalize for speed, normalize for accuracy [OK]
Hint: Denormalize for speed, normalize for accuracy in critical data [OK]
Common Mistakes:
  • Denormalizing everything causing data errors
  • Normalizing all data causing slow reads
  • Ignoring trade-offs between speed and accuracy
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard