Slowly changing dimensions (SCDs) are used in data warehouses to capture changes in dimensional attributes. Dimensions such as products and customers can change over time. To ensure accurate historical reporting, the data warehouse must capture and maintain these changes.
A Type 2 slowly changing dimension (SCD) creates a new record when dimensional data changes and marks the existing record as inactive. This approach preserves historical data by maintaining multiple versions of the same dimension record.
Type 2 slowly changing dimensions (SCD) maintain a history of dimension changes using the following attributes:
Consider a type 2 product dimension that captures price fluctuations. The original data is shown.

When the product price changes, a new row is inserted to capture the updated price. The original row is then marked as inactive by setting an end date and updating the active flag.

Type 3 slowly changing dimensions maintain historical changes by keeping both the old and new values of an attribute within the same row. The latest value is updated in the primary column, and the previous value is moved to another column that is used to track changes. Since each change is stored in a new column, Type 3 slowly changing dimensions (SCDs) can maintain only a limited amount of historical data.
Consider a type 3 product dimension that captures price fluctuations. The original data is shown.

When the price changes, the new value is captured in the Price column and original value is moved to the PreviousPrice column.
