Purpose
The Gold layer delivers:Star Schema
Dimensional model optimized for analytics queries
Business Context
Data enriched with business meaning and relationships
Query Performance
Denormalized structures for fast query response
Self-Service Analytics
Easy-to-understand models for business users
Star Schema Architecture
The Gold layer implements a classic star schema with one fact table and two dimension tables:The star schema design allows for simple, efficient joins and intuitive query patterns for business analysts.
Dimension Tables
dim_customer
Provides a 360-degree view of customers by combining CRM and ERP data sources.Customer Attributes
Customer Attributes
Key Fields:
customer_key: Surrogate key for dimensioncustomer_id: Natural key from source systemcustomer_number: Business key for customer lookupfirst_name,last_name: Customer name attributesmarital_status: Single, Married, or n/agender: Male, Female, or n/a (with ERP fallback)birth_date: Date of birth from ERP systemcreate_date: Customer creation date in CRM
Data Integration
Data Integration
This dimension integrates data from three Silver tables:
- silver.crm_cust_info: Primary customer attributes
- silver.erp_cust_az12: Birth date and gender (fallback)
- silver.erp_loc_a101: Location information
Gender is sourced from CRM, with ERP data used as fallback when CRM has ‘n/a’.
Surrogate Key
Surrogate Key
Uses This provides a stable, integer key for fact table joins.
ROW_NUMBER() to generate a sequential surrogate key:dim_product
Provides comprehensive product information with category hierarchy.Product Attributes
Product Attributes
Key Fields:
product_key: Surrogate key for dimensionproduct_id: Natural key from source systemproduct_number: Business key for product lookupproduct_name: Product name/descriptioncategory_id: Category identifiercategory: Product category (e.g., Bikes, Accessories)subcategory: Product subcategory for detailed groupingmanteinance: Maintenance classificationproduct_cost: Standard cost of productproduct_line: Mountain, Road, Touring, Other salesproduct_start_date: Product effective date
Category Hierarchy
Category Hierarchy
Product categorization is enriched from ERP data:This enables drill-down analysis from category to subcategory to individual products.
Active Products Filter
Active Products Filter
The dimension only includes currently active products:
Surrogate Key
Surrogate Key
Uses
ROW_NUMBER() ordered by start date and product key:Fact Table
fact_sales
Contains sales transactions with foreign keys to dimension tables.Fact Attributes
Fact Attributes
Key Fields:
order_number: Sales order identifier (degenerate dimension)product_key: Foreign key to dim_productcustomer_key: Foreign key to dim_customerorder_date: Date order was placedshipphing_date: Date order was shipped
sales_amount: Total sales valuequantity: Number of units soldprice: Unit price
Grain
Grain
The grain of the fact table is:This allows analysis at the order line level with the ability to aggregate to order or customer level.
One row per order line item - Each row represents a single product on a sales order.
Measures & Calculations
Measures & Calculations
The fact table provides these measure types:
- Additive
- Semi-Additive
- Derived
These measures can be summed across all dimensions:
sales_amount: Total revenuequantity: Total units sold
Dimension Joins
Dimension Joins
Fact table uses LEFT JOINs to dimensions:
Analytics Use Cases
- Sales by Product Line
- Customer Demographics
- Monthly Sales Trends
- Product Performance
Data Refresh
Gold layer views are automatically refreshed when queried since they’re based on Silver tables:Gold views are not materialized, so they always show current data from Silver tables. For better performance on large datasets, consider materializing these views.
Best Practices
Always Join on Keys
Use surrogate keys (customer_key, product_key) for joins, not natural keys
Filter Early
Apply date filters before joining to reduce dataset size
Index Dimensions
Consider indexing frequently filtered dimension attributes
Monitor Orphans
Check for NULL dimension keys in fact table
Next Steps
ETL Procedures
Learn how to orchestrate the complete pipeline
Silver Layer
Understand data transformations feeding Gold layer