A slowly changing dimension (SCD) is a dimension table whose descriptive attributes change infrequently and unpredictably, together with the set of techniques used to record those changes in a data warehouse. In Data modeling for analytical Databases, the SCD pattern decides whether a report shows facts with the attribute values that were true at the time of the event or with the values that are true today.
The concept comes from dimensional modeling, where facts such as sales or shipments are stored in a fact table and described by dimensions such as customer, product or employee. A customer moving to a new region or a product changing category is a typical change: it happens rarely compared with transactions, yet ignoring it silently distorts historical analysis.
How a slowly changing dimension preserves history
A slowly changing dimension preserves history by deciding, for each attribute, what happens when its source value changes. The load process compares incoming source rows with existing dimension rows, detects differences and then overwrites, versions or annotates the record according to the chosen technique.
The mechanism relies on the separation of two keys. The natural key (also called the business key) identifies the real-world entity, such as a customer number from the operational system. The surrogate key is a warehouse-generated integer that identifies one specific version of that entity, and fact rows reference the surrogate key, not the natural key.
Because each fact points to the version that was current when the fact was loaded, historical reports stay stable even after attributes change. The table below lists the columns that a versioned dimension typically carries.
| Column | Purpose | Example value |
|---|---|---|
| Surrogate key | Identifies one version of the entity | 48213 |
| Natural key | Links all versions of the same entity | CUST-00917 |
| Effective date | Start of the period when the version was valid | 2025-03-01 |
| Expiration date | End of the validity period | 9999-12-31 for the current row |
| Current flag | Marks the active version for fast filtering | Y or N |
| Row hash | Detects attribute changes efficiently | Checksum of tracked columns |
Types of slowly changing dimensions
The types of slowly changing dimensions are numbered techniques from Type 0 to Type 7, popularized by Ralph Kimball and now standard vocabulary in data warehousing. Types 1 and 2 cover most real designs, while the others address specific reporting needs.
| Type | Change handling | History kept | Typical use |
|---|---|---|---|
| Type 0 | Value never changes after first load | Original value only | Date of birth, original signup channel |
| Type 1 | Old value is overwritten | None | Spelling corrections, nonanalytical attributes |
| Type 2 | New row with a new surrogate key | Full history | Customer region, product category |
| Type 3 | Previous value stored in an extra column | One prior value | Planned reorganizations with before and after views |
| Type 4 | Volatile attributes moved to a history table | Full history, separated | Rapidly changing attributes such as scores |
| Type 6 | Combines Types 1, 2 and 3 | Full history plus current value | Reports needing both as-was and as-is views |
Types 5 and 7 are hybrid patterns that add mini-dimensions or dual foreign keys to give fact tables both historical and current perspectives. They are less common and usually appear only in large enterprise warehouses with demanding analytical requirements.
One dimension table can mix several types at the attribute level. A customer dimension might treat the name as Type 1, the sales region as Type 2 and the loyalty tier as Type 3, which is why the decision is documented per column rather than per table.
Choosing the right SCD technique
The right SCD technique depends on the analytical question the business needs to answer. If analysts must attribute last year’s revenue to the region a customer belonged to last year, the attribute needs Type 2; if only the current value matters, Type 1 is simpler and cheaper.
The following decision table connects common requirements to a recommended type.
| Requirement | Recommended type | Reason |
|---|---|---|
| Correct a data entry error | Type 1 | The old value was never true |
| Report facts as they were at the time | Type 2 | Each fact keeps its original context |
| Compare old and new structure side by side | Type 3 | Both values sit in one row |
| Track an attribute that changes daily | Type 4 or mini-dimension | Avoids explosive Type 2 row growth |
| Need as-was and as-is in one query | Type 6 | Current value is copied to every version |
Storage and load cost grow with history. A Type 2 dimension can multiply its row count when tracked attributes change often, so designers restrict Type 2 tracking to attributes with real analytical value and move volatile attributes elsewhere.
Implementing SCD logic in data pipelines
Implementing SCD logic means building a load step that detects changes, expires old versions and inserts new ones atomically. In SQL this is commonly done with a MERGE statement or with an update followed by an insert inside one transaction, and many ETL tools and frameworks such as dbt snapshots generate this logic automatically.
Change detection usually compares a hash of the tracked columns rather than each column individually, which keeps comparisons fast on wide tables. Fact loads then perform a point-in-time lookup, matching each fact to the dimension version whose effective and expiration dates contain the transaction date.
Late-arriving data complicates this process. When a fact arrives for a date before the current version began, the pipeline must find the version valid on that earlier date, and when a dimension change arrives late, existing facts may need to be reassigned.
Common mistakes with slowly changing dimensions
Most problems with slowly changing dimensions come from inconsistent keys and date handling. The table below lists frequent symptoms, their causes and the usual fixes.
| Symptom | Likely cause | Fix |
|---|---|---|
| Duplicate current rows | Expiration step failed or ran twice | Enforce one current row per natural key |
| Facts double counted | Join on natural key instead of surrogate key | Join facts on the surrogate key |
| Gaps between versions | Inconsistent date boundaries | Use one inclusive or exclusive convention |
| History rewritten unexpectedly | Attribute configured as Type 1 by mistake | Document and review type per column |
| Dimension grows too fast | Volatile attribute tracked as Type 2 | Move it to a mini-dimension |
Understanding it simply
A slowly changing dimension is a way of keeping old records instead of erasing them when details about a customer or product change. Think of an address book where, instead of crossing out an old address, you add a new line with the date of the move.
Later, when you look at a past purchase, you can see where the customer lived at that time, not only where they live now. That simple habit keeps past reports honest and stops old numbers from shifting every time something changes.
Applied in practice
A national insurance company reorganizes its sales regions on January 1, moving about 12,000 customers from the Central region to a new Midwest region. The analytics team had modeled the customer region as a Type 2 attribute, so the nightly load expires each affected customer row with an expiration date of December 31 and inserts a new version with the Midwest region and a new surrogate key.
When finance reviews prior-year premiums, every policy sold last year still links to the Central version of the customer, so last year’s regional totals stay exactly as originally reported. Meanwhile, new policies link to the Midwest version. The team also adds a Type 6 current-region column, which lets managers restate history under the new structure in a separate view, without altering the official historical figures.