TICKIT-03: SCD Type 2 Seller Dimension: Historical Sales Attribution
Track: TICKIT Marketplace • Difficulty: Advanced • Mastery Points: 200 PTS
Business Problem Scenario
Marketplace ticket sellers frequently relocate between cities and states. For accurate tax jurisdiction reporting and historical sales attribution, completed transactions must be tied to the seller's verified address at the exact moment of the sale, rather than their current profile address. You must write an 'as-of' point-in-time join query against the Slowly Changing Dimension Type 2 table gold.dim_user_scd2 joining on the seller's natural key (s.seller_sk = u.user_id) within temporal bounds.
Engineering Objective
Write an 'as-of' point-in-time attribution query connecting gold.fact_sales s to gold.dim_user_scd2 u. • Expected Columns: s.salesid, s.seller_id, u.city AS seller_historical_city, u.state AS seller_historical_state, s.saletime, s.pricepaid • Temporal Boundary: Join on s.seller_id = u.user_id AND s.saletime BETWEEN u.effective_from AND u.effective_to. Key Concepts: - Point-in-Time Dimension Attribution: Resolving seller operational jurisdiction and tax nexus at historical transaction moment rather than contemporary state.
Target Table: gold.fact_sales s (salesid INT, seller_id INT, seller_sk BIGINT, saletime TIMESTAMP, pricepaid DECIMAL(10,2)), gold.dim_user_scd2 u (user_sk BIGINT, user_id INT, city STRING, state STRING, effective_from TIMESTAMP, effective_to TIMESTAMP, is_current BOOLEAN)
Verification & Architecture Insights
Point-in-time SCD2 joins preserve statutory sales tax and regional cohort attribution integrity across years of customer profile evolution.