FOUNDATIONS-6: Bronze → Silver → Gold: The Data Prep Line
Track: Analytics Foundations • Difficulty: Beginner • Mastery Points: 150 PTS
Business Problem Scenario
Think of a restaurant kitchen: Bronze is dirty vegetables straight from the truck, Silver is washed and chopped ingredients, and Gold is the plated meal served to customers. In bronze.orders_events, an order can arrive multiple times as its status updates from 'pending' to 'paid'. We need a clean Silver view that keeps only the latest event per order_id.
Engineering Objective
Deduplicate bronze.orders_events to keep only the latest status per order. • Expected Columns: order_id, customer_id, status, amount • Rules: - Exclude rows where amount <= 0. - Partition by order_id and order by updated_at DESC. - Keep rn = 1 and order final output by order_id ASC.
Target Table: bronze.orders_events (order_id, customer_id, status, amount, updated_at)
Verification & Architecture Insights
Medallion Architecture separates raw ingestion (Bronze), clean deduplicated records (Silver), and business-ready summaries (Gold). `ROW_NUMBER() OVER (PARTITION BY id ORDER BY updated_at DESC)` is the gold-standard Silver deduplication pattern.