TICKIT-13: Social Graph Co-Attendance: Event Companion Discovery
Track: TICKIT Marketplace • Difficulty: Intermediate • Mastery Points: 150 PTS
Business Problem Scenario
To drive organic community ticket demand, TICKIT's growth engineering team wants to identify pairs of registered friends who co-attended live entertainment events together. If a query joins undirected friendship connections naively, it outputs mirrored duplicate pairs (e.g. both Alice-Bob and Bob-Alice). You must write a social graph co-attendance query projecting canonical pairs (LEAST and GREATEST) and filtering personid < friendid to eliminate mirrored duplicates.
Engineering Objective
Write a social graph co-attendance query joining silver.friend f with silver.sales for each person. • Expected Columns: person_a, person_b, count(DISTINCT a.eventid) AS events_together • Graph Canonicalization Logic: - Canonical pairs: LEAST(a.personid, f.friendid) AS person_a, GREATEST(a.personid, f.friendid) AS person_b. - Symmetry breaking: Filter a.personid < f.friendid. - Event co-attendance: Match a.eventid = b.eventid. - Group by person_a, person_b. Key Concepts: - Canonical Undirected Edges: Using LEAST/GREATEST with symmetry breaking to prevent duplicated bipartite graph pairs.
Target Table: silver.friend f (personid INT, friendid INT), silver.sales s (salesid INT, buyerid INT, eventid INT)
Verification & Architecture Insights
Canonical pair projection eliminates graph traversal permutations, allowing standard SQL engines to perform social network analytics efficiently.