CLOUD CONCEPT

Slowly Changing Dimensions

Slowly Changing Dimensions is a data-modeling approach for deciding how changes to descriptive attributes are overwritten, retained, or versioned over time.

Cloud Concepts Hub →

What is Slowly Changing Dimensions

Dimension tables describe business entities such as customers, products, and locations whose attributes can change independently of transactional facts. Slowly Changing Dimensions (SCD) techniques control whether reports use current attributes or the attributes that were valid when an event occurred, preserving the historical meaning required by the business.

Slowly Changing Dimensions addresses changes to the descriptive characteristics of business entities in analytical data models. A customer can move to a different region, a product can change category, and an employee can transfer departments. The central design question is whether historical analysis should reflect the old value, the current value, or both. Despite the name, the technique does not require changes to occur infrequently; change frequency mainly affects storage, processing cost, and model suitability.

Choose a change policy for each relevant attribute rather than assuming every column needs identical treatment. Type 0 retains the original value and ignores subsequent changes to that attribute. Type 1 overwrites the stored value without retaining its previous value in the dimension. It is appropriate for corrections or attributes whose history is unnecessary. For example, correcting a misspelled customer name usually does not justify creating another historical customer version.

Type 2 preserves history by creating a new dimension row when tracked attributes change. Each version normally receives a distinct surrogate key, while the business key continues to identify the same source entity. Effective-start and effective-end timestamps describe when the version applies, and a current-row flag can simplify current-state queries. If customer C42 moves from East to West on July 1, the East version ends on July 1 and the West version begins then. Half-open validity intervals, where the start is inclusive and the end is exclusive, avoid ambiguity at the boundary.

Fact rows should reference the dimension version appropriate to the business event time. A June sale for C42 should retain its association with East even if the sale is loaded after the July move. Pipelines can resolve the surrogate key using the business key and the event timestamp during loading. Alternatively, suitable models can use time-range joins, although these require careful query design. Joining historical facts to only the current customer row incorrectly reclassifies earlier sales.

Type 3 stores limited history in additional columns, such as current_region and previous_region. It supports a defined comparison but does not preserve an unlimited sequence of changes. Hybrid approaches are possible when different reporting requirements coexist. On exam questions, overwriting points toward Type 1, preserving every accepted historical version points toward Type 2, and retaining a fixed previous value points toward Type 3.

In cloud pipelines, change data capture or periodic snapshots supply candidate changes. Transformation logic compares incoming records with the applicable stored state, using selected-column comparisons or consistently calculated hashes. Hash inputs require stable handling of nulls, data types, and formatting. Only actual changes to tracked attributes should create new versions. Change data capture transports source changes; it does not by itself choose or implement the correct SCD policy.

A Type 2 load commonly stages and deduplicates incoming records, expires affected current versions, and inserts replacements within an atomic transaction or table-format commit. A MERGE statement can assist, but its availability does not automatically make the process a correct Type 2 implementation. Preserve ordering when multiple changes for one entity arrive together, make retries idempotent, and validate that validity intervals do not overlap and that each active business entity has exactly one current version. Late-arriving changes may require splitting an existing interval and reassessing affected fact references.

Type 2 increases row counts, transformation work, and temporal-join complexity in exchange for historical fidelity. Separate genuine business changes from corrections, define how deletions are represented, and distinguish business-effective time from ingestion time. SCD is also different from schema evolution: adding or changing a column alters table structure, whereas changing a customer's region alters an entity's attributes. Both may require pipeline updates, but they solve different problems.

Key aspects of Slowly Changing Dimensions

SCD combines explicit history policies, version identity, effective-time rules, and reliable change processing to keep analytical results meaningful as entity attributes change.

Attribute-level history policy

Choose whether each attribute remains fixed, is overwritten, or retains history according to reporting requirements. A single customer dimension can overwrite spelling corrections while versioning region changes.

Established SCD types

Type 0 retains the original value, Type 1 overwrites it, Type 2 adds historical row versions, and Type 3 keeps limited history in additional columns. Select the simplest approach that preserves the required business meaning.

Business keys and version keys

The business key identifies an entity across changes, while a Type 2 surrogate key identifies one specific version. Facts referencing the appropriate version retain their original historical context.

Effective-time semantics

Use explicit validity intervals and consistent boundary rules to determine which version applies to an event. Distinguish when a change became effective in the business from when the pipeline received it.

Reliable change processing

Detect changes only in tracked attributes, process multiple changes in a defined order, and make reruns idempotent. Atomic updates and inserts prevent partially applied version transitions.

Historical integrity and validation

Check for overlapping validity intervals, duplicate current versions, and facts linked to the wrong version. Establish explicit handling for late-arriving changes, corrections, and deleted entities.

Cloud services for Slowly Changing Dimensions

AWS DMS can deliver source changes to Amazon S3, where raw records provide a replayable input for dimension processing. AWS Glue can normalize keys, detect tracked-attribute changes, and build dimension versions in supported lake table formats. Amazon Redshift can maintain warehouse dimensions and join facts to the appropriate versions, while Amazon Athena can query lake-based history and perform supported Iceberg mutations. Across these paths, the pipeline must explicitly implement the SCD policy, ordering, effective dates, and retry behavior; capturing changes or retaining files alone does not guarantee historically correct reporting.

Amazon Redshift image Amazon Redshift

Stores dimensional models and supports SQL transformations for Type 1 updates and Type 2 version maintenance. Staging tables, transactions, and carefully designed update-and-insert logic help apply changes consistently; MERGE alone does not define the history policy.

Open Amazon Redshift →
AWS Glue image AWS Glue

Runs data integration jobs that compare incoming records with existing dimension state, calculate change indicators, and construct historical versions. With supported transactional table formats such as Apache Iceberg, jobs can maintain dimension tables in a data lake.

Open AWS Glue →
Amazon Simple Storage Service image Amazon S3

Stores raw change records, source snapshots, and historical dimension data for lake-based pipelines. S3 object versioning is not a substitute for row-level SCD history; a transactional table format and processing engine can provide the required table-level operations.

Open Amazon S3 →
Amazon Athena image Amazon Athena

Queries current and historical dimension data stored in Amazon S3. Athena engine version 3 supports MERGE INTO for Apache Iceberg tables, enabling SQL-based change application when the surrounding logic correctly manages historical versions.

Open Amazon Athena →