Normalization là quá trình tổ chức database để giảm data redundancy và dependency thông qua các Normal Forms (1NF, 2NF, 3NF, BCNF) – chia data thành nhiều tables liên quan, tránh duplicate data.
Lợi ích: storage hiệu quả, dễ maintain consistency khi update (chỉ cần update một chỗ), ít risk inconsistency.
Nhược điểm: cần nhiều JOINs để reconstruct data, JOINs tốn kém ở scale lớn. Denormalization là cố tình thêm redundant data để tăng read performance – ví dụ lưu username trong bảng posts thay vì JOIN với bảng users mỗi lần query.
Lợi ích: read queries nhanh hơn đáng kể, đơn giản hóa query.
Nhược điểm: duplicate data tốn storage, phức tạp khi update (phải update nhiều chỗ), risk inconsistency. Quyết định: OLTP (transaction processing) thường normalize để đảm bảo data integrity; OLAP (analytics, data warehouse) thường denormalize (star/snowflake schema) để tăng query speed. Với NoSQL Document DB, denormalization là mặc định – embed related data vào document nếu luôn được đọc cùng nhau.
Normalization is the process of organizing a database to reduce data redundancy and dependency through Normal Forms (1NF, 2NF, 3NF, BCNF) — splitting data into related tables and eliminating duplicate data.
Benefits: efficient storage, easy consistency maintenance on updates (only one place to update), lower risk of inconsistency. Drawbacks: requires many JOINs to reconstruct data, and JOINs become expensive at scale. Denormalization intentionally adds redundant data to improve read performance — for example, storing the username in the posts table instead of joining with the users table on every query.
Benefits: significantly faster read queries, simpler query logic. Drawbacks: duplicate data wastes storage, updates are complex (must update multiple places), and there is a risk of inconsistency. Decision guide: OLTP (transaction processing) typically uses normalization to ensure data integrity; OLAP (analytics, data warehousing) typically uses denormalization (star/snowflake schema) for query speed. With NoSQL document databases, denormalization is the default — embed related data in the document when it is always read together.