0
0
HLDsystem_design~12 mins

Database normalization vs denormalization in HLD - Architecture Patterns Compared

Choose your learning style9 modes available
System Overview - Database normalization vs denormalization

This system explains the difference between database normalization and denormalization. Normalization organizes data to reduce duplication and improve consistency. Denormalization combines data to speed up read operations at the cost of some duplication.

Key requirements include balancing data integrity, query speed, and storage efficiency depending on the use case.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  +-------------------+
  |                   |
Cache (Normalized)   Cache (Denormalized)
  |                   |
Normalized DB      Denormalized DB
  |                   |
Response            Response
Components
User
user
Initiates requests to the system
Load Balancer
load_balancer
Distributes incoming requests evenly to API Gateway
API Gateway
api_gateway
Routes requests to either normalized or denormalized database services
Normalized DB
database
Stores data in normalized form to reduce duplication and maintain integrity
Denormalized DB
database
Stores data in denormalized form to optimize read performance
Cache (Normalized)
cache
Caches frequently accessed normalized data to reduce DB load
Cache (Denormalized)
cache
Caches frequently accessed denormalized data for faster reads
Response
response
Sends processed data back to the user
Request Flow - 8 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayCache (Normalized or Denormalized)
Cache (Normalized or Denormalized)API Gateway
API GatewayNormalized DB or Denormalized DB
Normalized DB or Denormalized DBAPI Gateway
API GatewayCache (Normalized or Denormalized)
API GatewayResponse
Failure Scenario
Component Fails:Cache (Normalized or Denormalized)
Impact:Cache misses increase, causing more direct database queries and higher latency
Mitigation:System falls back to database queries; cache is rebuilt over time; consider cache replication or failover
Architecture Quiz - 3 Questions
Test your understanding
Which component reduces database load by storing frequently accessed data?
ALoad Balancer
BCache
CAPI Gateway
DUser
Design Principle
This architecture demonstrates the trade-off between normalization and denormalization in databases. Normalization ensures data integrity and reduces duplication, while denormalization improves read speed by storing combined data. Caches are used to optimize performance by reducing database load. The system routes requests through load balancers and API gateways to maintain scalability and control.