Slowly Changing Dimensions

lowly Changing Dimensions are used in data warehousing to manage and track changes in dimension data over time. In many systems, information about customers, products, employees, or locations can change. Instead of losing old data, Slowly Changing Dimensions allow organizations to store the history of these changes.

A dimension is a descriptive attribute or characteristic of data. For example, a customer dimension may include information such as name, address, city, and phone number. If a customer moves to a new city or changes their phone number, the system needs a method to handle these updates without losing the previous information.

Slowly Changing Dimensions are important in data warehouses because businesses often analyze historical data. For example, a company might want to know which city a customer lived in when a purchase was made in the past. Without tracking these changes, reports and analytics could become inaccurate.

TYPES OF SLOWLY CHANGING DIMENSIONS

TYPE 0

In this type, the original data is never changed. Once the information is stored in the database, it remains the same permanently. If the source system sends new data, the existing value is not updated.

Example
A person’s date of birth should never change. Once it is recorded in the system, it stays the same forever.

TYPE 1

Type 1 replaces the existing data with the new value. The previous information is removed, and only the latest value is stored. This method is simple and is used when keeping historical data is not necessary.

Example
If a product description has a spelling mistake, the incorrect text can be replaced with the correct one.

TYPE 2

Type 2 keeps the complete history of changes by creating a new record whenever an update happens. Each record usually contains additional fields such as start date, end date, and a current status indicator.

Example
If a customer changes their city, a new record is added with the updated city. The previous record remains in the table with an end date that shows when it stopped being active.

TYPE 3

Type 3 stores limited historical data by adding extra columns to the same record. One column may store the current value, and another column may store the previous value.

Example
An employee table may contain a column for the current department and another column for the previous department.

TYPE 4

Type 4 keeps the current data in the main dimension table and stores historical data in a separate history table. This approach helps keep the main table small while still preserving past information.

Example
The customer table contains the current address, while a customer history table stores previous addresses.

TYPE 6

Type 6 is a hybrid approach that combines the features of Type 1, Type 2, and Type 3. It allows systems to maintain historical records while also storing current and previous values in the same structure.

IMPORTANCE OF SLOWLY CHANGING DIMENSIONS

Slowly Changing Dimensions help organizations maintain accurate historical records. They allow analysts to understand how data has evolved over time and make better decisions based on past trends.

In modern data warehousing and business intelligence systems, Slowly Changing Dimensions play an important role in ensuring reliable reporting, data consistency, and long term data analysis.

If you want, I can also convert this into perfect HTML website content (with H1, H2, H3 tags and formatting for your website) which will look much better on your training site.

Home » SQL for Data Engineering (SQL-DE) > SQL in Data Warehousing > Slowly Changing Dimensions