Wednesday, August 12, 2026

187 ) How to handle (Slowly Changing Dimensions)

 How do you handle updates or changes to Dimension attributes that are already linked to historical Fact table records? 

or How to handle (Slowly Changing Dimensions)



Answer:

We handle this using Slowly Changing Dimension (SCD) Type 2.

  •  If a customer changes their home address or risk category,
  • we do not overwrite the old row in Dim_Customer. 
  • Instead, we expire the old row by setting an end-date and status flag,
  •  and we insert a brand-new row with the updated details and a new surrogate key. 
  • This way, past claims and policy sales linked to that customer will always point to the customer's address and details as they looked at the time the transaction happened.

No comments:

Post a Comment

215 ) query : Customers Purchasing the Same Product in Different Stores in Same Month

  /*  ### Step 1: DDL & DML (Sample Data Setup) ```sql -- 1. Create Orders Table */ DROP TABLE customerorders ; CREATE TABLE custome...