GlossaryData modeling

Slowly changing dimension (SCD)

Also: SCD · SCD type 2

A pattern for handling dimension attributes that change over time. Type 1 overwrites the old value; Type 2 keeps history by adding a new row with valid-from/valid-to dates.

When a customer changes address or a product moves category, you have to decide what happens to your dimension. Slowly changing dimension (SCD) patterns name the options.

Type 1 simply overwrites the old value — you keep only the current state and lose history. It's simple and fine when history doesn't matter. Type 2 preserves history: instead of updating, you close the old row (set its valid-to date) and insert a new row with the new value and an open valid-to. Facts then join to the dimension row that was current at the event's timestamp.

Type 2 is the one that comes up in interviews and on the job, because “what did this look like at the time?” is a question stakeholders ask constantly. dbt has snapshots specifically to build Type 2 dimensions.

Why it matters

Point-in-time correctness is a real business requirement: finance needs to know a customer's tier at the moment of a sale, not today. SCD Type 2 is how you answer 'what was true then?' without rebuilding history by hand.

Choosing the wrong SCD type is expensive to fix later — once you've overwritten history (Type 1), it's gone. Deciding history requirements up front is part of modeling.

Common mistakes
  • Using Type 1 (overwrite) when the business later needs historical values you've already destroyed.
  • Forgetting to join facts to the dimension version that was current at the event time, so historical reports use today's attributes.
  • Building Type 2 by hand instead of using dbt snapshots, leading to subtle valid-from/valid-to bugs.
FAQ
What is SCD Type 2?
A slowly changing dimension pattern that preserves history: when an attribute changes, you close the existing row (valid-to date) and insert a new row with the new value, so every historical state is queryable.
How does dbt handle slowly changing dimensions?
dbt snapshots implement Type 2 for you — they detect changes in a source and maintain the valid-from/valid-to history automatically.
Related terms

Go deeper in the Data Modeling hub.

Learn this by building, not memorizing.

Definitions get you the vocabulary. The platform gets you the skill — graded exercises, real projects, and a portfolio capstone.