Slowly Changing Dimension Type 2 Generator
Builds a Type 2 dimension table and its load statement from a CREATE TABLE statement.
Loading the tool…
How to use this tool
- Paste the CREATE TABLE statement for the source table.
- Name the business key columns if the primary key in the DDL is not the natural key.
- Set the dimension and staging table names, then select Generate dimension.
- Review the null handling and the identity syntax against your platform before running any of it.
What scd type 2 generator does
A Type 2 dimension keeps history by closing the old row and opening a new one whenever a tracked attribute changes, which is easy to describe and fiddly to implement. The surrogate key, the validity dates, the current flag and the null handling all have to line up, and a mistake in any of them shows up months later as a total that cannot be reconciled.
This generates the dimension DDL and the load statement from the source table definition, with the business key and the tracked columns worked out from the DDL unless you name them. Treat it as a starting point rather than a finished job: the identity syntax is PostgreSQL, and how you handle a null in a tracked column is a modelling decision no generator should make for you.