Denormalization is a database optimization technique that combines tables to reduce joins and improve query performance by introducing some level of redundancy.
Denormalization is often used in read-heavy applications like data warehouses, where performance is prioritized over data redundancy. Instead of splitting data into multiple normalized tables, it is merged into fewer tables to reduce complex joins.
Example of Denormalization:
Instead of separate Customers
and Orders
tables, we can merge them:
sqlCopyEditCREATE TABLE OrderDetails (
order_id INT PRIMARY KEY,
customer_name VARCHAR(100),
product_name VARCHAR(100),
product_price DECIMAL(10,2)
);
Here, customer details are repeated, but queries will be faster since fewer joins are needed.
Leave a Reply