Real world SCD scenarios. No toy examples.
This template uses actual warehouse-style data changes you’ll see on the job
address updates, corrections, history tracking, and hybrid patterns.
👉 Copy paste SQL into your favorite SQL editor
👉 Re-run queries
👉 Observe how rows change before vs after
Works with:
MySQL, SQL Server, PostgreSQL, Snowflake, Redshift, BigQuery
(any system supporting standard SQL logic)
CREATE TABLE dim_customer (
surrogate_key INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
customer_id INTEGER,
name VARCHAR(100),
current_city VARCHAR(50),
previous_city VARCHAR(50),
start_date DATE,
end_date DATE,
is_current BOOLEAN
);
⚠️ MySQL users
Replace
GENERATED ALWAYS AS IDENTITYwithAUTO_INCREMENT