originates from https://www.nuwavesolutions.com/slowly-changing-dimensions/
Slowly Changing Dimensions
Slowly Changing Dimensions (SCD) are the most commonly used advanced dimensional technique used in dimensional data warehouses. Slowly changing dimensions are used when you wish to capture the changing data within the dimension over time. There are three methodologies for slowly changing dimensions.
Type 0 – Retain Original
this information would never change
Type 1 –Overwrite
Type 2 –Add new row
- Add a new row in the dimension with the updated attribute values
- Requires generalizing the PK of the dimension beyond the natural key because multiple rows apply to the same attribute
- A minimum of three columns should be added:
- Row effective date
- Row expiration date
- Current row indicator
This is the most commonly used type of slowly changing dimension. For this type of slowly changing dimension, add a new record encompassing the change and mark the old record as inactive.
This allows the fact table to continue to use the old version of the data for historical reporting purposes leaving the changed data in the new record to only impact the fact data from that point forward. Several columns should be added to the dimension table (active record start/end dates and a current active record flag) to provide historical change management and ensure optimal use of the active record.
This new dimension key will be used in the generation of the fact table moving forward. This allows the fact table to still use the data stored under the old dimension key for historical reporting. This will ensure that the data remains the same and a historical report for the same timeframe run before the update was made will continue to display the exact same data as before the change was made.
Original Record
Inserted / Updated Records
Type 3 –Add new attribute
- Add a new attribute in the dimension to preserve the old value
- New value overwrites the main attribute similar to type 1 change
- Sometimes called “alternate reality”
This is a seldom-used type of slowly changing dimension. In this type of slowly changing dimension, you add a second column to store the most recent past value of the column(s) you wish to be able to report on. When the data is updated the existing value is “moved” to the column defined to store the previous past value and the new value is placed into the reportable column.
This allows you the ability to look back at what the value of the data was previously. This can be a challenge when loading/updating the data. The amount of work to design and maintain this solution far exceed the benefit the “fallback snapshot” provides.
Original Record
Updated Record
Type 6 -combine SCD Type 1, SCD Type 2 and SCD Type 3
(1 + 2 + 3 = 6)
A Type 6 SCD is a very rarely used SCD
To create a Type 6 SCD you would start with a Type 2, add columns for the records you wish to capture the current value as well as the historical value. This allows one to filter or group on the Type 2 value in effect when the measure occurred or the current attribute value.
Original Record
1 Update
2 Update
Conclusion
As you can see there are many ways to capture the changes in dimensions for current and historical reporting purposes. Because of the flexibility, I recommend that you start all design solutions using SCD Type 2 as your default solution. Keep in mind that not all attributes need to be captured as a Type 2 SCD. I often combine Type 1 and Type 2 SCDs based on the project requirements.