| Users / Data Size | Normalized DB | Denormalized DB |
|---|---|---|
| 100 users | Simple joins, low redundancy, easy updates | Fast reads, some data duplication, simple queries |
| 10,000 users | More joins, moderate query complexity, good data integrity | Faster read queries, larger storage, update complexity grows |
| 1 million users | Joins become expensive, slower queries, DB CPU load rises | Read-heavy workloads scale well, write/update latency increases |
| 100 million users | Joins cause major slowdowns, DB scaling hard without sharding | Massive storage needs, complex update logic, caching essential |
Database normalization vs denormalization in HLD - Scaling Approaches Compared
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.
- 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.
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.
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.
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.
Practice
database normalization?Solution
Step 1: Understand normalization purpose
Normalization organizes data to minimize duplication and maintain consistency.Step 2: Compare with other options
Combining tables and increasing storage are characteristics of denormalization, not normalization.Final Answer:
To reduce data duplication and improve data accuracy -> Option AQuick Check:
Normalization = reduce duplication [OK]
- Confusing normalization with denormalization
- Thinking normalization increases storage
- Believing normalization makes queries faster
denormalization?Solution
Step 1: Identify denormalization effect
Denormalization merges tables to reduce joins and speed up reads.Step 2: Eliminate incorrect options
Reducing redundancy and splitting tables are normalization traits; strict integrity is also normalization.Final Answer:
It combines tables to speed up read queries -> Option BQuick Check:
Denormalization = combine tables for speed [OK]
- Mixing up normalization and denormalization goals
- Assuming denormalization reduces redundancy
- Thinking denormalization splits tables
Solution
Step 1: Analyze denormalization impact on reads
Combining tables reduces joins, so read queries speed up.Step 2: Analyze impact on writes
More data in one table means writes may take longer due to larger rows and possible duplication.Final Answer:
Read queries become faster, write queries may slow down -> Option DQuick Check:
Denormalization = faster reads, slower writes [OK]
- Assuming writes always get faster
- Ignoring join cost in normalized reads
- Believing no performance change occurs
Solution
Step 1: Understand denormalization risk
Duplicating data can cause inconsistencies if updates are not synchronized.Step 2: Evaluate consequences
Failing to update all copies leads to conflicting data, harming accuracy.Final Answer:
Data inconsistency due to redundant copies -> Option AQuick Check:
Denormalization risk = inconsistency if not managed [OK]
- Assuming denormalization always improves integrity
- Ignoring update complexity in denormalized data
- Thinking denormalization reduces storage
Solution
Step 1: Identify system needs
Fast product search benefits from denormalization to reduce joins and speed reads.Step 2: Consider order history requirements
Order history needs accuracy and consistency, so normalization is better.Step 3: Choose balanced approach
Denormalize product data for speed, normalize order data for integrity.Final Answer:
Denormalize product data for fast search, normalize order history for accuracy -> Option CQuick Check:
Balance = denormalize for speed, normalize for accuracy [OK]
- Denormalizing everything causing data errors
- Normalizing all data causing slow reads
- Ignoring trade-offs between speed and accuracy
Ready to prove it?
Pass the test and this pattern moves unknown
