Analytics Foundations
Start here! Beginner-friendly labs covering Primary Keys, money types, Facts vs. Dimensions, JOIN fan-out, NULLs, and Bronze-Silver-Gold cleaning.
Curriculum Labs (6)
Tables, Rows & Spotting Duplicate Primary Keys
Welcome to your first analytics lab! Imagine a spreadsheet of customers where each person is supposed to appear exactly once. Yesterday, an app bug saved the same customer twice. If a manager counts rows in this table, they will double-count customers and report inflated signups.
Money Math, Data Types & Cleaning Dirty Orders
A small online coffee shop logs every checkout in bronze.coffee_orders. Unfortunately, the test team left negative test amounts (-5.00) in the table, and cancelled orders still sit next to completed orders. If finance sums every row, daily revenue will be wrong.
Facts vs. Dimensions: Combining Orders & Customers
In a well-designed data warehouse, we split data into two kinds of tables: Fact tables (things that happen, like orders) and Dimension tables (who/where/what, like customers). Your manager wants to know total sales per city, but city lives in gold.dim_customers while order amounts live in gold.fact_orders.
The JOIN Fan-Out Trap (Why Revenue Doubled!)
A junior analyst joined gold.fact_orders (one row per order, with shipping_fee) directly to gold.fact_order_items (one row per item inside an order, with item_price). Because Order #100 had 3 items, its $10 shipping fee was added 3 times ($30 instead of $10)! This is the #1 most common SQL bug in analytics.
Handling Missing Data: NULL, COALESCE & Blank Strings
In real databases, missing data shows up in two sneaky ways: actual NULLs and blank empty strings (' '). If you don't handle both, automated email reports crash or skip customers.
Bronze → Silver → Gold: The Data Prep Line
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.