TICKIT-01: Grain, Keys and the Two-Fact Model
Track: TICKIT Marketplace • Difficulty: Beginner • Mastery Points: 100 PTS
Business Problem Scenario
TICKIT Marketplace connects secondary ticket sellers with event buyers across sports matches, concerts, and theatrical productions. An analyst mistakenly joined inventory listings and completed ticket sales directly at the raw row level. Because a single listing can be split across multiple buyer transactions over time, the direct join produced catastrophic Cartesian fan-out, inflating reported gross merchandise value by 300%. To resolve this reporting defect, you must construct an audit query that respects the distinct business grains of listings and sales.
Engineering Objective
Write an analytical audit query against raw.sales and raw.listing respecting their distinct business grains. • Expected Columns: eventid, total_listings, total_sales_txns, total_tickets_sold, gross_merchandise_value • Aggregation Logic: - Group by eventid. - total_listings = count(distinct l.listid) - total_sales_txns = count(distinct s.salesid) - total_tickets_sold = sum(s.qtysold) - gross_merchandise_value = sum(s.pricepaid) • Core Learning Principle: Pre-aggregating listings and sales separately at event grain prevents Cartesian explosion and eliminates revenue duplication. Key Concepts: - Business Grain: The fundamental atomic operational unit represented by an individual table row. - Two-Fact Model: Dimensional architecture keeping inventory listings and sales transactions in distinct fact tables to prevent Cartesian fan-out.
Target Table: raw.listing l (listid, sellerid, eventid, dateid, numtickets, priceperticket, totalprice, listtime), raw.sales s (salesid, listid, sellerid, buyerid, eventid, dateid, qtysold, pricepaid, commission, saletime)
Verification & Architecture Insights
In two-sided marketplace models, conflating inventory state with settlement events produces phantom revenue. Preserving separate grains prevents reporting discrepancies.