Skip to content
Back to challenges
SCD DepthConcept Challengeintermediate20 min

Product price and category history

Build a Type 2 product dimension with full validity metadata and a fact-to-surrogate-key join.

How this preview works
Preview this problem before signing in. Sign in to save progress and submit work.

Concept

slowly-changing-dimensions

The primary modeling idea this problem reinforces.

Requirements

5

Business needs the model must satisfy.

Read the concept guide: Slowly changing dimensions: Type 2
Scenario

A commerce merchandising team changes product price and category over time. Finance needs order revenue by the product price and category that were valid when each order item was purchased, while operations still needs an easy way to find the current product row.

Why this matters

A Type 2 dimension is only useful when it preserves both the version identity and the validity window. Without a surrogate row key, effective dates, and current-row signaling, historical joins become fragile.

Requirements
  • Add a product dimension with a surrogate primary key and natural product id attribute.
  • Track price and category as versioned product attributes.
  • Version with an effective-from and point order items at the product version surrogate key, so revenue is reportable as of the order date (the floor).
  • Grade up by closing each version with an effective-to, then adding a current-row flag for the operations current-lookup need.
  • Declare an N:1 relationship and foreign key from order items to the product surrogate key.
Read-only starter workspace
Inspect the authored starting ERD, then open the workspace to edit and run the checks. Saving your progress needs a free account.

Template

Product catalog history 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.

Mini Map

This preview is read-only. Open the workspace to edit and verify; saving needs a free account.

Open workspace

Try the question first.

The discussion has other people's approaches and solutions. Give it a real attempt before you read them.