🚀

SCD Types 3 and 6

Advanced SCD patterns for specific requirements.

Section 1 of 3: SCD Type 3: Previous Value Column0%

SCD Type 3: Previous Value Column

Study Material

SCD Type 3: Add Column for Previous Value

Instead of adding rows, add columns to store both current and previous values.

How It Works:

Customer moves from NY to CA:

Structure:

customer_keycustomer_idcurrent_stateprevious_statestate_change_date
1001CUST001CANY2024-03-15

When to Use Type 3:

Only need ONE level of history
Before/after comparisons
"New vs Old" reporting
Limited storage constraints
Simple queries (no date range logic)

Real-World Examples:

1. Sales Territory Realignment

  • "Compare performance under old territory vs new"
  • current_territory, previous_territory

2. Pricing Changes

  • "Compare sales at old price vs new price"
  • current_price, previous_price

3. Organizational Restructuring

  • "Compare metrics under old department vs new"
  • current_department, previous_department

Limitations of Type 3:

Only stores ONE previous value
Multiple changes? Only keep most recent change
Cannot answer "what was state on date X?"
Complex for multiple tracked attributes
Not suitable for audit requirements

Example Query:

"Show me customers who recently changed states"

SELECT

customer_id,

current_state,

previous_state,

state_change_date

FROM dim_customer

WHERE current_state != previous_state

AND state_change_date >= CURRENT_DATE - 30;