Denormalization
- SQL course
- Expert
- Lesson 5/45
- 5 min
Learn the deliberate repeat scenario.
Denormalization
Denormalization adds deliberately copied columns to a normalized table to speed up reads. Writes get more costly but read queries simplify.
-- orders tablosuna customer_name ekle
-- JOIN gereği azalır, okuma hızlanırDenormalization speeds up reads.
Denormalization — details
Denormalization helps in reporting and OLAP workloads. In OLTP systems it is used with care due to write anomaly risk.
Practice Denormalization
Add a customer_name TEXT column to orders for denormalization.
Starter code
-- denormalization
ALTER TABLE ordersSample solution
ALTER TABLE orders
ADD COLUMN customer_name TEXT;Expected output
ALTER TABLE
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Add a column to the table
ALTER TABLE orders ADD COLUMN ____ TEXT
ALTER TABLE orders ADD COLUMN customer_name TEXT
Explanation: customer_name is the right answer.
2 Denormalization: match the terms
| Term | Meaning |
|---|---|
normalize |
split |
denormalize |
merge |
OLAP |
report |
OLTP |
transaction |
3 What does denormalization increase?
- Write speed
- The number of tables
- Read speed Correct answer
- It reduces disk size
Explanation: Denormalization increases read speed.