Schema Mode
Interactiveinfo Normalized (3NF)
JOIN Users ON Orders.uid = Users.id... // Slow
Normalization organizes data into multiple related tables to minimize redundancy.
Denormalization combines data into fewer tables to optimize read performance at the cost of redundancy.
Reduces data redundancy and inconsistency by dividing larger tables into smaller tables and linking them using relationships.
Intentionally adds redundancy by combining tables. Used primarily to speed up read operations in complex systems.
| Normalization | Denormalization |
|---|---|
| Stores non-redundant, consistent data | Combines data for faster execution |
| Redundancy is minimized | Redundancy is intentionally added |
| Maintains Data Integrity | Integrity is harder to maintain |
| Optimizes Disk Space | Consumes More Disk Space |
| Slower Reads (Joins needed) | Faster Reads (Fewer/No Joins) |
| Best for: OLTP (Banking, Transactions) | Best for: OLAP (Analytics, Reporting) |
Database design is a trade-off between organization and speed. Let's look at real-world examples.
In a library, every book has exactly one spot. If you need to correct a title, you do it once. However, finding all books by an author on a specific topic requires walking to different aisles (Joins).
Like a pre-packed grocery kit. It contains milk, eggs, and bread together. You grab one kit and go (Fast Read). But if milk expires, you have to check every single kit to replace it (Expensive Update).
Master the "Why" and "When".
Unable to add data because other dependent data is missing (e.g., Can't add a student without a course).
Data inconsistency when updating. (e.g., Update address in one row but miss others).
Accidental loss of data. (e.g., Deleting a course also deletes the only student record).
"Every fact must be about the key, the whole key, and nothing but the key."