Slowly Changing
Dimensions
Learning Objectives
u Slowly Changing Dimensions (SCD)
u SCD Types
u SCD vs. Delta Time Travel
Slowly Changing Dimensions
u Slowly Changing Dimensions (SCD)
u Data management concept that determines how tables handle
data which change over time
u Whether you want to overwrite values or retain their history
SCD Types
u Type 0: No changes allowed
u Static/Append only
u Type 1: Overwrite
u No history retained (use Delta Time Travel if needed)
u Type 2: Add new row for each change and mark the old as obsolete
u Retains the full history of values.
SCD Type 1
Product ID Product Name Price
1 Product A 10
2 Product B 20
3 Product C 30
SCD Type 1
Product ID Product Name Price
1 Product A 50
2 Product B 20
3 Product C 70
SCD Type 2
Product ID Product Name Price Current Effective Date End Date
1 Product A 10 True 2023-01-01 NULL
2 Product B 20 True 2023-01-01 NULL
3 Product C 30 True 2023-01-01 NULL
SCD Type 2
Product ID Product Name Price Current Effective Date End Date
1 Product A 10 False 2023-01-01 2023-02-25
2 Product B 20 True 2023-01-01 NULL
3 Product C 30 False 2023-01-01 2023-02-28
1 Product A 50 True 2023-02-25 NULL
3 Product C 70 True 2023-02-28 NULL
SCD Type 2
Product ID Product Name Price Current Effective Date End Date
1 Product A 10 False 2023-01-01 2023-02-25
2 Product B 20 True 2023-01-01 NULL
3 Product C 30 False 2023-01-01 2023-02-28
1 Product A 50 True 2023-02-25 NULL
3 Product C 70 True 2023-02-28 NULL
SCD Type 2 vs. Delta Time Travel
u Can we use Delta Time Travel as SCD Type 2 ?
u Delta Time Travel is not a long-term versioning solution