We’re moving to a new home! Our website is currently in test mode while we update and transfer our content. Some pages and resources may be temporarily unavailable. We’ll be back with all resources shortly. Thank you for your patience.

IB Computer Science | A3.2.7 Evaluating Denormalization

Lesson objective

Evaluate when denormalization is justified by weighing read performance and simpler queries against redundancy, update costs and consistency risks.

Learn

A3.2.7 | EVALUATING DENORMALIZATION

01 | WHY WOULD WE REINTRODUCE DUPLICATION?

An online shop displays product information thousands of times, but its category names change only occasionally. A normalized design keeps each category name in one place. Every product listing may join PRODUCT and CATEGORY to display that name.

Suppose measurements show these reads are too slow, even after appropriate query and index tuning. Could storing a copy of the category name beside each product help?

Denormalization deliberately introduces redundancy or stores combined or precomputed data to support particular queries. It trades some simplicity of maintenance for potentially faster reads. It is a deliberate design decision—not a reason to ignore dependencies.

Start from an understood, normalized model. Change selected parts only when the expected benefit is worth the cost.

02 | THE NORMALIZED DESIGN

CATEGORY(CategoryID PK, CategoryName)

PRODUCT(ProductID PK, ProductName, CurrentPrice, CategoryID FK)

CATEGORY: one name per category
CategoryID (PK)CategoryName
C10Robotics
C20Programming
PRODUCT: category names are not repeated here
ProductID (PK)ProductNameCurrentPriceCategoryID (FK)
P01Servo kit25.00C10
P02Sensor kit18.00C10
P03Python guide12.00C20

To show a product with its category name, join the two tables through CategoryID. This is normal relational database work. With suitable indexes and a good execution plan, the join may already be fast enough.

Rename C10 once in CATEGORY and every query using current source data sees the new name. This is a major advantage when consistency matters.

03 | A DENORMALIZED READ TABLE

PRODUCT_LISTING: prejoined data for displaying products
ProductIDProductNameCurrentPriceCategoryIDCategoryName
P01Servo kit25.00C10Robotics
P02Sensor kit18.00C10Robotics
P03Python guide12.00C20Programming

A listing query can now obtain the displayed fields from one structure. It may avoid repeatedly joining the category data, but the category name is duplicated.

Notice the dependency: ProductID → CategoryID → CategoryName. If PRODUCT_LISTING is treated as a normal base table under these rules, the category name creates a non-key transitive dependency. That is the deliberate trade-off.

A safer option may be to keep PRODUCT and CATEGORY as the authoritative source and generate PRODUCT_LISTING as a read model. If the source changes, the read model must be refreshed.

04 | WHAT HAPPENS WHEN A NAME CHANGES?

An inconsistent update: the same category now has two displayed names
ProductIDCategoryIDCategoryName
P01C10Robotics & Engineering
P02C10Robotics

In a directly maintained denormalized table, renaming a category may require updates to every associated row. A missed row creates an update anomaly. More affected rows can also mean more work during writes.

In a periodically refreshed read model, old values may be intentional until the next refresh. This is staleness: the read copy lags behind the source. It still needs a clear freshness policy and users must not assume it is current.

Prevent accidental inconsistency by defining one source of truth, coordinating dependent updates, checking copies, and providing a rebuild or refresh process. The exact mechanism depends on the database and the application.

05 | COMPARE THE TRADE-OFFS

Advantages and disadvantages depend on the workload
ConcernNormalized designDenormalized design
RedundancyReduces repeated factsAdds selected repeated or derived data
ConsistencyOne location for many facts makes updates easierCopies or summaries must be synchronized
ReadsMay need joins or calculationsCan avoid selected joins or repeated calculations
WritesUsually fewer copies of a fact to changeMay require extra updates or refresh work
StorageOften less repeated dataUsually more storage for copies or summaries
Query structureMay be more complex for cross-table reportsCan be simpler for the targeted read
FlexibilitySupports different queries over reusable entitiesOften tailored to specific queries
MaintenanceMaintain source constraints and relationshipsAlso maintain refresh logic and derived structures

“Denormalized means faster” is too broad. Wider rows, extra storage, synchronization overhead and different query patterns can offset the benefit. Likewise, normalization does not automatically make every write or query fast.

06 | READ-INTENSIVE APPLICATIONS

A read-intensive workload has frequent retrievals compared with changes. Examples include product catalogues, public reporting dashboards and some analytics systems. Repeating an expensive join or aggregation for many users can justify a precomputed result.

It is not just the read/write ratio that matters. Ask whether the slow operation is actually a join or repeated calculation, how frequently the copied facts change, and how current the result must be.

Evaluate each use case, not just its industry
SituationPossible benefitMain caution
Daily sales dashboardPrecompute daily totals rather than scan all sales for every viewLate sales or corrections require refreshed totals
Public product cataloguePrejoin commonly displayed product and category fieldsPrice and availability may need fresher data than descriptions
Clinical patient updatesA read model may support a separate reportTreatment decisions require appropriate current authoritative data
Rapidly changing stockA summary may accelerate browsingDo not authorize purchases using a stale stock count

A write-intensive transaction system with frequently changing facts may gain little from duplicated fields. A separate reporting model can let an organization keep normalized transactions while supporting faster analytical reads.

07 | PRECOMPUTE A SUMMARY

Source order lines
OrderLineIDProductIDQuantity
L01P012
L02P013
L03P021
Derived sales summary: the totals are stored for fast retrieval
ProductIDUnitsSold
P015
P021

A report can read UnitsSold rather than add every order-line quantity again. However, a returned item, cancelled order or corrected quantity can change the correct total. The summary needs the same business definition as the report and must be maintained accordingly.

A materialized view stores a query result. Unlike a normal non-materialized view, it can avoid recomputing that result on each read. Depending on the system, it may be maintained automatically or refreshed separately. Maintenance still costs work.

A normal view can simplify SQL text without storing a redundant copy. Therefore, simpler query text alone is not proof of denormalization or improved performance.

08 | CONSIDER ALTERNATIVES FIRST

  • Indexes: suitable indexes can reduce searching and improve joins, with their own write and storage costs.
  • Query tuning: retrieve only needed rows and fields; inspect how the database executes the query.
  • Ordinary views: make repeated query definitions easier to use without necessarily storing their results.
  • Caching: reuse a result where its lifetime and invalidation rules are appropriate.
  • Selective read models: keep the authoritative schema normalized and denormalize only a targeted reporting structure.

Measure realistic workloads before and after a change. Compare read latency, write latency, storage, refresh cost and freshness. A result on one small test dataset is not enough to guarantee production performance.

09 | EVALUATE WITH EVIDENCE

“Evaluate” means weighing both sides and reaching a justified conclusion for the scenario. Use benefit → cost → conditions → recommendation.

Illustrative test figures only; assume a reliable hourly refresh
MeasureNormalizedWith hourly summary
Dashboard reads per day100,000100,000
Typical dashboard response900 ms80 ms
Daily maintenance workNo summary refresh12 minutes of refresh work
Reporting-data freshnessCurrent source dataUp to about one hour old

Sample evaluation: the summary improves the measured report response substantially, benefiting a frequently read dashboard. It adds storage and maintenance and can show older values. If the report tolerates approximately one-hour-old data and refresh costs are acceptable, keep the normalized source and use the summary for this report. If the same data supports a decision requiring current stock, use an appropriately current source for that decision.

A refresh failure can make data older than the normal refresh interval. Monitoring and a visible “last updated” time help users assess this risk.

10 | KEEP DIFFERENT FACTS DISTINCT

Do not mistake historical facts for redundant copies. In A3.2.6, UnitPriceAtOrder is the price actually charged, while CurrentPrice is today’s product price. They describe different facts and should not be kept equal.

Likewise, repeatedly storing a foreign key to represent relationships is normal. Denormalization concerns deliberately repeated or derived facts, not merely any repeated value.

Decision checklist: what query is slow, what evidence shows the cause, what will be copied, where is the source of truth, how often does it change, how fresh must it be, and how will it be repaired if updates fail?

Further reading: Microsoft’s materialized view pattern.

CLASSIFY THE TRADE-OFF

Match each statement to the most relevant issue.

Terminology

Terminology

Denormalization

Deliberately storing redundant, combined or precomputed data to support selected queries.

Normalization

Organizing relational tables according to dependencies to reduce unnecessary redundancy and anomalies.

Read-intensive workload

A workload with frequent data retrieval compared with changes.

Redundancy

Repeated or derived facts stored in additional locations.

Consistency

Representations of the same current fact agree according to the system’s rules.

Staleness

A copy or summary is older than the current source data.

Source of truth

The authoritative location from which copies are derived.

Materialized view

A stored query result, with a maintenance or refresh mechanism.

Ordinary view

A named query definition that does not normally store its result independently.

Refresh

Updating a derived structure from its source.

Latency

The time taken to respond to an operation.

Workload

The actual mix, volume and patterns of database operations.

Questions

Questions

CHECK YOUR UNDERSTANDING

Select all correct choices. One point per exact set.

1. Which can be advantages of selective denormalization?
2. Which are potential costs?
3. Which is a stronger case for a maintained summary?
4. Which statements about views are correct?
5. Which should be checked before a redesign?
6. Which describes the category-name update risk?
7. Why keep UnitPriceAtOrder and CurrentPrice separately?
8. Which make a justified evaluation?

EVALUATION PRACTICE

Answer in your book. Include a benefit, a cost, conditions and a justified recommendation. These are original practice tasks, not official IB questions or mark schemes.

1. Explain two advantages and two disadvantages of normalization.

2. A product catalogue has millions of reads and rare category-name changes. Evaluate copying category names into a read table.

3. A stock count changes every few seconds. A proposed sales system uses a report refreshed hourly to approve purchases. Evaluate the proposal.

4. A dashboard accepts one-hour-old data and measured response falls from 900 ms to 80 ms with an hourly summary. Give a balanced recommendation.

5. Explain how denormalization can simplify a query yet complicate the application.

6. Compare an ordinary view with a materialized view.

7. Suggest three checks before deciding to denormalize.

8. A developer says every repeated value is evidence of denormalization. Evaluate this claim.

Flashcards

Flashcards

Click to flip. Select the ideas you need to revisit.

0 cards selected for revision.

    Selections are kept while this page is open.

    Workbook

    Workbook

    COMING SOON

    The A3.2.7 workbook is coming soon. Use the evaluation questions to practise evidence-based recommendations in your book.