Professional Documents
Culture Documents
DENORMALIZED
DATA AHEAD
Example
Technique:
Add duplicate fields
Technique:
Add computed fields
Example
Technique:
Join tables
Less common denormalization techniques
• Duplicating a commonly-used subset of table fields
• Splitting some table rows into different tables
• Frequently- vs. rarely-used data
• Data for different regions
• Common subclasses of data
When to denormalize?
Techniques:
• Stored procedures act as API for updating DB. They add the redundant data.
• Triggers check (and fix?) consistency.
• Application code carefully maintains consistency during updates.
• Reconcile data as background process.
• Reconcile data during system maintenance.
Dimensional modeling
In a tiny, brief nutshell
An alternative to ER modeling
College(collegeid, …)
Teach(crn, instr_id, …)
Typical:
• Few cycles.
Instructor(instr_id, …) • Super/sub classes implemented
only with superclass table.
Starflakes can be compressed to stars
Star = junction table & one level of child tables in 1-to-many relationships
Teach(crn, instr_id, …)
Denormalize by joining each child’s tree.
Instructor(instr_id, …)
Fact & dimension tables
Facts: The junction tables are the most important data – the facts
• E.g.: store purchases, class enrollments, click data
• Generally the largest tables
• Key data often numeric & additive – e.g., quantity bought, cost per unit,
advertisement views
OrderLine
Store Order
order_id
store_id order_id
sku
store_name customer_id
promotion_id
address store_id
dollars_sold
district clerk_id
units_sold
floor_type date
dollars_cost
Clerk Promotion
clerk_id promotion_id
clerk_name promotion_name
clerk_grade price_type
ad_type
Customer Product
customer_key
customer_name
Dimensional product_key
sku
purchase_profile
credit_profile model description
brand
address category
Order
time_key
Store
store_key
store_key Promotion
clerk_key
store_id promotion_key
product_key
store_name promotion_name
customer_key
address price_type
promotion_key
district ad_type
dollars_sold
floor_type
units_sold
dollars_cost
Time
Clerk time_key
clerk_key SQL_date
clerk_id day_of_week
clerk_name month
clerk_grade
View fact table as -dimensional data cube