pattern

Slowly Changing Dimension

also called SCD

A strategy for handling attributes that change over time, deciding whether history is preserved and how facts attach to the correct version.

warehousehistorydimensions

A customer moves from London to Manchester. Should last year's sales now appear under Manchester? There is no universally correct answer, which is why the types exist.

Type 0 — never changes. Fixed attributes. Type 1 — overwrite. No history; last year's sales move to Manchester. Simple, and it silently rewrites the past, which is why it is wrong for anything used in reporting comparisons. Type 2 — add a new row with effective-from and effective-to dates and a current flag. The most common answer for anything with reporting significance: history preserved, and each fact links to the dimension row that was current when it happened. Type 3 — add a column for the previous value. Keeps one level of history only. Type 4 — current values in the main dimension, history in a separate table. Type 6 — a hybrid of 1, 2 and 3 giving both current and historical views.

The consequential decision is per attribute, not per table: an address may need Type 2 while a formatting preference needs Type 1.

And Type 2 is what makes surrogate keys non-negotiable in a warehouse — the natural key repeats across versions, so facts must reference the version, not the entity.