🚀

SCD Type 2: Historical Tracking

The gold standard for complete history preservation.

Section 1 of 4: Type 2 Concept0%

Type 2 Concept

Study Material

SCD Type 2: Create a New Row

When data changes, keep the old row and create a new one. This preserves complete history - the most powerful SCD type.

How It Works:

Customer Sarah moves from NY to CA on March 15, 2024:

Before (1 row):

customer_keycustomer_idstateeffective_dateexpiration_dateis_current
1001CUST001NY2023-01-019999-12-31TRUE

After (2 rows):

customer_keycustomer_idstateeffective_dateexpiration_dateis_current
1001CUST001NY2023-01-012024-03-14FALSE
2547CUST001CA2024-03-159999-12-31TRUE

Key Components:

1. Surrogate Key (customer_key)

  • Unique per VERSION, not per customer
  • Customer CUST001 now has TWO surrogate keys
  • Fact tables link to specific versions

2. Natural Key (customer_id)

  • Same across all versions
  • Identifies the business entity

3. Effective Date (effective_date)

  • When this version became active
  • Start of validity period

4. Expiration Date (expiration_date)

  • When this version ended
  • '9999-12-31' = still current (convention)
  • Or use NULL for current

5. Current Flag (is_current)

  • Easy way to find current record
  • Only ONE row per customer has TRUE

Why This Works:

  • Fact tables link to customer_key (surrogate)
  • Sarah's Q1 orders link to key 1001 (NY version)
  • Sarah's Q2 orders link to key 2547 (CA version)
  • Historical accuracy preserved automatically!