20.0 KB · commit 40bb182
← Previous: T08.9: Boyce-Codd Normal Form (BCNF) and 3NF vs. BCNF | 🏠 Index | Next: T08.11: Lossless-Join Decomposition and Dependency Preservation →
Topic: T08 — Normalization & Functional Dependencies | Priority: 🟡 | Exam Frequency: 0/7 finals (0 marks) [Cross-ref: 2017 Q.3(a) in T08.06] Sources: Silberschatz 7e Ch. 7 (§7.9.3, §7.1.3) · Lecture Deck 06 (Slides 47–51) · Classnote by Raidah (p. 23)
Normalization is the backbone of relational database design because it removes duplicate data and protects your tables from insertion, update, and deletion anomalies. However, splitting data across lots of small tables comes with a real-world catch: every time an application wants to display a complete record, the database has to run expensive JOIN operations across all those tables. In read-heavy systems, joining five or six tables on every page load can slow queries to a crawl. To speed things up, database designers sometimes intentionally put controlled redundancy back into a normalized schema, a technique called denormalization. In RUET exams, this topic tests how well you understand the practical engineering trade-off between write safety and read speed.
Normalization: Normalization is the database design process of splitting relations into smaller, well-structured tables (such as 3NF or BCNF) to remove unnecessary redundancy and prevent insertion, deletion, and update anomalies.
Denormalization: Denormalization is the deliberate process of adding controlled redundancy back into an already normalized schema by merging tables or duplicating columns. Designers use it to reduce expensive
JOINoperations and speed up time-critical read queries.
Materialized View: A materialized view is a database view whose precomputed query result is physically stored on disk and automatically updated when its underlying base tables change. It gives the fast read speed of denormalization while keeping the base schema cleanly normalized.
Normalizing a database gives you six major design benefits that keep data clean and easy to maintain (Lecture Deck 06 Slide 47):
Elimination of Data Redundancy: Every fact is stored in one single place, which saves disk space and prevents conflicting copies of the same data.
Prevention of Update Anomalies: When a fact changes (such as an instructor's address), you only have to update one row in one table instead of hunting down dozens of rows in a giant combined table.
Prevention of Insertion Anomalies: You can record new entities right away without waiting for other relationships to exist. For example, you can add a new department even before it hires its first instructor.
Prevention of Deletion Anomalies: Deleting a relationship does not wipe out the entities themselves. Dropping the last student from a course will not accidentally delete the course or instructor from the database.
Stronger Data Consistency and Integrity:
Because each table represents one clear concept, the DBMS can easily enforce primary keys, foreign keys, and CHECK constraints on individual tables.
Easier Database Maintenance: Smaller, narrower tables are much easier to index, back up, and modify without locking up the entire database.
Even though normalization is great for data integrity, pushing it too far creates performance headaches in production systems (Lecture Deck 06 Slide 48):
Table Proliferation: Normalizing a large business system splits data into dozens or even hundreds of small tables, making the schema harder to navigate.
Heavy JOIN Overhead: Putting the pieces back together for a user screen or report requires joining multiple tables, which burns CPU cycles, disk I/O, and memory buffer space.
Slower Read Performance: When high-traffic queries have to join five or six tables across millions of rows, response times drop noticeably.
More Complex SQL Queries:
Developers have to write long multi-table JOIN queries for routine tasks, which takes longer to write and makes bugs harder to spot.
Extra Index Overhead: Every split table needs its own primary key index and foreign key indexes, which eats back some of the disk space saved by removing duplicate columns.
Denormalization is the deliberate act of adding controlled redundancy back into a schema that has already been normalized (Lecture Deck 06 Slide 49, Silberschatz 7e §7.9.3).
Normalized Schema (3NF / BCNF)
│
│ Apply Controlled Redundancy (Pre-join tables, store aggregates)
▼
Denormalized Schema
├── Fewer JOIN operations
├── Faster read performance
└── Trade-off: Slower updates, extra storage, application-managed consistency
It is important to remember that denormalized is not the same thing as unnormalized. An unnormalized table is what you get when nobody designed the schema properly in the first place. Denormalization happens after you design a clean 3NF or BCNF schema, spot a real read-performance bottleneck, and selectively merge two tables or duplicate a column so your most frequent queries can run without expensive joins.
A database designer should reach for denormalization in four specific situations (Lecture Deck 06 Slide 50):
When 90% or more of your database traffic consists of SELECT queries (like an online product catalog or news site), speeding up reads is worth paying a small penalty on writes.
When a core user-facing feature has to join several big tables and return results in a few milliseconds, pre-joining those columns removes the bottleneck.
Online Analytical Processing (OLAP) systems and data warehouses scan millions of historical rows to build charts and reports. They regularly use Star or Snowflake schemas that store pre-joined dimension columns and pre-calculated totals.
If an application constantly runs SUM(), COUNT(), or AVG() across thousands of child rows (like counting total likes or calculating an account balance), storing that running total directly on the parent row avoids scanning the child table every time.
In practice, database engineers use four main techniques to denormalize a schema:
Instead of maintaining separate tables for related entities, combine them into a single relation.
Example:
CUSTOMER(CustomerID, CustomerName, Address)ORDERS(OrderID, OrderDate, CustomerID, Amount)ORDERS(OrderID, OrderDate, CustomerID, CustomerName, Address, Amount)Benefit: Queries displaying orders with customer names require zero joins.
Penalty: If a customer changes address, every historic order must be updated.
Add one or two heavily requested attributes from a parent table directly into a child table.
Example:
In a university database, relation STUDENT_SECTION(StudentID, SectionID, Grade) stores student enrollments. Course title is frequently queried alongside grades. Adding CourseTitle to STUDENT_SECTION eliminates joining through SECTION to COURSE.
Store summary metrics directly in parent tables rather than computing them dynamically.
Example:
In a banking schema, table ACCOUNT(AccountID, Balance, TotalTransactions) stores TotalTransactions. Every time a deposit or withdrawal row is inserted into TRANSACTION, ACCOUNT.TotalTransactions is incremented.
ORDERS_2023, ORDERS_2024).The table below contrasts the two design paradigms across key operational dimensions (Lecture Deck 06 Slide 51).
| Criterion | Normalization | Denormalization |
|---|---|---|
| Primary Goal | Eliminate redundancy and prevent anomalies | Maximize read performance and reduce join latency |
| Data Redundancy | Minimized to zero | Controlled redundancy introduced deliberately |
| Table Structure | Many narrow, highly specialized tables | Fewer, wider tables containing combined attributes |
| Query Complexity | Complex SQL with multiple JOIN operations | Simpler SQL queries requiring fewer or no JOINs |
| Read Speed | Slower for complex queries due to join costs | Fast and efficient for targeted read queries |
| Write Speed (Insert/Update) | Fast (single row modified in one table) | Slower (multiple redundant copies must be updated) |
| Data Integrity Risk | Very low (enforced via relational constraints) | High (application must synchronize duplicate values) |
| Storage Requirement | Lower physical disk space | Higher disk space due to repeated attributes |
| Typical Environment | OLTP (Online Transaction Processing systems) | OLAP (Data warehouses, analytics, reporting) |
Silberschatz 7e (§7.9.3, p. 346) points out that modern relational DBMS engines offer a much cleaner alternative to manual denormalization: materialized views.
A normal SQL VIEW is just a saved query. Every time you SELECT from a normal view, the database still has to run the underlying JOIN from scratch.
A materialized view, on the other hand, actually computes the join once and saves the result table on disk. Whenever a query reads from the materialized view, the DBMS serves the precomputed rows straight from disk without re-running the join.
When you denormalize base tables by hand, your application code has to remember to update every duplicate column whenever data changes. If a bug in your code misses one copy, your data becomes corrupted.
With materialized views, you get the best of both worlds:
The table below summarizes how normalization pros/cons and denormalization can appear on exams.
| Year & Question | Marks | Scenario / Data Given | Key Result / Answer Summary |
|---|---|---|---|
| 2017 Q.3(a) | 5 | "Define normalization. What is the importance of normalization?" (Cross-ref T08.6) | Covered importance and advantages of normalization (denormalization was not asked) |
| Likely Question 1 | 4–6 | Pros and cons of normalization in database design | Redundancy and anomaly removal vs. table proliferation and join latency |
| Likely Question 2 | 4 | Define denormalization and explain when it is beneficial | Controlled redundancy for read-heavy OLAP systems vs. write overhead |
| Likely Question 3 | 4–5 | Normalization vs. Denormalization comparison | Side-by-side feature table and materialized views as a modern alternative |
Likely Question: High-Probability Exam Problem — (5 marks)
Question:
Define normalization. Discuss the principal advantages and disadvantages of normalizing a relational database schema.
Full Answer:
Normalization is the systematic process of decomposing relation schemas to minimize data redundancy and eliminate operational anomalies (insertion, update, and deletion anomalies) while preserving data integrity and functional relationships.
JOIN operations, which consume CPU, memory buffers, and disk I/O.Likely Question: High-Probability Exam Problem — (4 marks)
Question:
What is meant by denormalization? Under what circumstances is denormalization justified, and what penalties does it introduce?
Full Answer:
Denormalization is the intentional process of introducing controlled redundancy or combining normalized tables into wider schemas. It is performed after normalization to improve read performance for time-critical queries.
A database designer chooses denormalization under the following circumstances:
INSERT, UPDATE, and DELETE operations.Likely Question: High-Probability Exam Problem — (5 marks)
Question:
Distinguish between normalization and denormalization using a comparative table. How can materialized views achieve the performance benefits of denormalization without compromising schema integrity?
Full Answer:
| Parameter | Normalization | Denormalization |
|---|---|---|
| Objective | Remove redundancy and anomalies | Boost read speed and reduce join latency |
| Redundancy | Minimized to zero | Controlled redundancy introduced deliberately |
| Number of Tables | Many smaller, specialized tables | Fewer, wider tables |
| Join Requirements | Frequent joins required for queries | Minimizes or eliminates joins |
| Read Performance | Slower for complex multi-table queries | Very fast for targeted reads |
| Write Performance | Fast and efficient | Slower due to duplicate updates |
| Integrity Enforcement | Handled natively by DBMS constraints | Handled by application logic or triggers |
| Target Application | OLTP (transaction processing) | OLAP (data warehouses, dashboards) |
A materialized view provides an elegant bridge between normalization and read performance:
← Previous: T08.9: Boyce-Codd Normal Form (BCNF) and 3NF vs. BCNF | 🏠 Index | Next: T08.11: Lossless-Join Decomposition and Dependency Preservation →