History versions and SCD policies
On this page
Historization compares warehouse input with stored history by business key. In the normal keyed path, an SCD2 change takes precedence when a row also has SCD1 changes. The policies are assigned per mapped column using SCD Type.
How a changed row is processed
| Incoming key and values | Usual keyed result |
|---|---|
| Key is new | Insert a first version with the configured initial validity start. |
| Only SCD0 values differ | Keep the current version. An SCD0 change alone does not trigger an update. |
| SCD1 values differ and no SCD2 values differ | Update SCD1 values in the eligible existing row in place. |
| One or more SCD2 values differ | Close the prior version and insert a successor according to the validity expressions. |
These cases assume a normal keyed load with a single eligible current version, one source row per key and a run in chronological order. Source-history reuse, future history and missing records change how intervals or absent rows are handled.
Worked example with Northwind Customers
This is an illustrative sequence to reproduce in an isolated copy. CustomerID is the business key. Assign CompanyName to SCD0, ContactName to SCD1 and City to SCD2. Use a half-open interval, where a version is valid through times strictly before ValidTo. Column names below are logical names. Use your configured surrogate key and validity names. SK values are illustrative, and “open” denotes your configured open-end value.
| Stage | Incoming change | Stored SK | CompanyName | ContactName | City | ValidFrom | ValidTo |
|---|---|---|---|---|---|---|---|
| Initial import for ALFKI | First snapshot | 101 | Alfreds Futterkiste | Maria Anders | Berlin | 2024-01-01 | open |
| 2024-02-01 | Only CompanyName changes | 101 | Alfreds Futterkiste | Maria Anders | Berlin | 2024-01-01 | open |
| 2024-03-01 | ContactName changes to Maria Hoffmann | 101 | Alfreds Futterkiste | Maria Hoffmann | Berlin | 2024-01-01 | open |
| 2024-04-01 | City changes to Potsdam, prior row | 101 | Alfreds Futterkiste | Maria Hoffmann | Berlin | 2024-01-01 | 2024-04-01 |
| 2024-04-01 | City changes to Potsdam, successor | 102 | Alfreds Futterkiste | Maria Hoffmann | Potsdam | 2024-04-01 | open |
For this example, keep CompanyName unchanged in the later inputs after the SCD0-only test. This isolates what each policy does when it first sees a change. Check the key, dates and number of rows after each run. Inclusive validity uses a different end boundary, so verify your validity fields and generated SQL before using these exact timestamps.