Slowly changing dimensions
Data Modelling · 12 questions
Short notes
Key idea
Dimension attributes change: customers move city, products change category. A slowly changing dimension (SCD) policy decides whether history is kept.
Syntax
- Type 0: never change (date of birth).
- Type 1: overwrite. No history; old facts now show the new value.
- Type 2: add a new row per change, with
valid_from,valid_to,is_currentand a new surrogate key. Full history. - Type 3: keep a "previous value" column. One step of history.
Example
Asha moves from Chennai to Pune in June. Type 2: her old row gets valid_to = 2024-05-31, is_current = false; a new row (new key) says Pune from 2024-06-01. Her May sales stay with Chennai; July sales go to Pune. Under Type 1, all her past sales would jump to Pune.
Traps
- Type 2 joins need the surrogate key stored in the fact at load time, or a date-range join.
- Counting customers on a Type 2 table counts versions; filter
is_currentor count distinct natural keys. - Not every column needs history; mix Type 1 and Type 2 per column.
- Overlapping validity ranges create double matches.
Want the full lesson with step-by-step examples, a project and a certificate? Data Modelling course, ₹120 →
Questions
5 free questions- Question 1easy
A customer moves city. With SCD Type 1, what happens to their past sales in reports?
- Question 2medium
In SCD Type 2, what happens when a tracked attribute changes?
- Question 3hard
dim_customer is SCD 2. Customer 7 has 3 versions. A fact row joins on customer_id (natural key) instead of the surrogate key. What happens to that sale?
- Question 4medium
A typo in a customer's surname is corrected. Which SCD type fits this change?
- Question 5easy
What question does an SCD strategy answer?
Slowly changing dimensions
Slowly changing dimensions
Slowly changing dimensions
Slowly changing dimensions
Slowly changing dimensions
7 more questions on this topic, with hints, and tests
Sign up free for 21 days of every question and test.