Avoid SCD2 row explosion
Split a frequently changing loyalty-points attribute out of the customer dimension.
Concept
slowly-changing-dimensions
The primary modeling idea this problem reinforces.
Requirements
4
Business needs the model must satisfy.
A retail loyalty team wants to analyze point balances and point adjustments by customer over time. The current customer dimension stores loyalty_points_current, but points can change many times per day after purchases, returns, promotions, and manual adjustments.
Type 2 is not the right answer for every changing attribute. Versioning the whole customer dimension for every point change creates row explosion and makes stable customer context noisy.
- Keep durable customer identity in a customer dimension.
- Add a loyalty point event or snapshot fact for point changes.
- Record loyalty event id, event time, and point balance or point delta.
- Connect loyalty point rows back to the customer surrogate key.
Template
Loyalty row-explosion starter workspace
The model users start from in the full workspace.
Entities
1
Seeded tables visible in the public preview.
Dialect
postgresql
Generated SQL target for this starter model.
This preview is read-only. Open the workspace to edit and verify; saving needs a free account.
Open workspaceTry the question first.
The discussion has other people's approaches and solutions. Give it a real attempt before you read them.