Schema Reference
Standard retail schema used across all contributions. Use these exact table and column names in your submissions.
Tables
Table |
Type |
Key Columns |
|---|---|---|
|
Fact |
|
|
Dimension |
|
|
Dimension |
|
|
Dimension |
|
|
Dimension |
|
Common Join Patterns
-- Sales with product and date
FROM fact_sales s
JOIN dim_product p ON s.product_id = p.product_id
JOIN dim_date d ON s.date_id = d.date_id
-- Sales with store
FROM fact_sales s
JOIN dim_store st ON s.store_id = st.store_id
-- Full star join
FROM fact_sales s
JOIN dim_product p ON s.product_id = p.product_id
JOIN dim_customer c ON s.customer_id = c.customer_id
JOIN dim_store st ON s.store_id = st.store_id
JOIN dim_date d ON s.date_id = d.date_id
Common Filters
-- Exclude returns
WHERE s.is_return = FALSE
-- Rolling 12-month window
AND d.full_date >= CURRENT_DATE - INTERVAL '12 months'
-- Rolling 90-day window
AND d.full_date >= CURRENT_DATE - INTERVAL '90 days'
-- Specific quarter and year
AND d.year = 2024 AND d.quarter = 4
-- Exclude newly opened stores
AND st.opening_date <= CURRENT_DATE - INTERVAL '90 days'