Enterprise Sales Reporting Data Mart
Design and build a high-performance dimensional sales reporting data mart in Snowflake with explicit grain definitions, conformed star schema dimensions, surrogate keys, Slowly Changing Dimensions (SCD), and proven financial reconciliation.
Project Brief
Understand the enterprise reporting challenge and dimensional data mart modeling requirements.
Business Scenario
The enterprise has successfully established a lakehouse processing pipeline that captures raw sales transactions into trusted Silver tables. However, business users across sales, marketing, and finance report severe difficulty querying these raw transaction-level datasets directly in BI tools (Power BI, Tableau) and SQL workbenches.
Analytical queries currently require expensive runtime table joins across unindexed transaction files, lack standardized business dimensions (Date, Store, Product, Customer), and produce conflicting revenue numbers due to disparate calculation logic across teams.
Development Objective
Design, model, and build a high-performance Enterprise Sales Reporting Data Mart in Snowflake. The data mart must establish explicit grain definitions, implement a dimensional Star / Snowflake Schema with Fact and Dimension tables, handle Slowly Changing Dimensions (SCD), enforce referential integrity, and publish pre-aggregated analytical views.
Expected Outcome
This task focuses on data modeling judgment and SQL/PySpark implementation. You must make explicit modeling decisions regarding dimensional grain, surrogate keys, null dimension handling (-1 key), and metric definitions (gross sales vs net sales vs discounts).
Source System
Inspect the input source datasets: trusted transactions and reference entity feeds.
Source Datasets Overview
The data mart consumes from two primary sources: trusted Silver transaction logs and operational dimension reference feeds.
Source Input Schema Entities
Known Source Constraints
The fact table must maintain 100% referential integrity with all conformed dimensions. No orphan foreign keys or dangling sales transactions are permitted in the production mart.
Expected Architecture
Dimensional model architecture: staging, surrogate key pipelines, conformed dimensions, and fact tables.
Data Mart Flow Architecture
The architecture transforms normalized transaction files into a dimensional schema optimized for analytical query workloads.
Dimensional Schema Design
Architectural Expectations
A data mart is judged by simplicity for analysts and speed of query execution. Avoid overly complex snowflaking where a clean star schema provides superior performance and readability.
Development Requirements
Implement the dimensional models, surrogate pipelines, SCD handlers, and Snowflake tables.
Developer Responsibilities
The implementation must address the following 15 engineering requirements across data modeling, transformation, reconciliation, and publishing.
Source Entity & Relationship Analysis
Analyze source schemas and define business entity boundaries.
Explicit Grain Definition
Define the fundamental grain of the sales fact table.
Dimension Modeling (Conformed Dimensions)
Design and implement conformed dimension tables.
Surrogate Key Generation Pipeline
Generate durable, integer-based surrogate primary keys.
Slowly Changing Dimensions (SCD) Implementation
Manage historical attribute changes in dimension tables.
Fact Table Modeling & Measure Calculation
Design and populate the central FACT_SALES table.
Referential Integrity Enforcement
Guarantee zero orphaned records across fact and dimensions.
Daily Aggregation Mart (Periodic Snapshot)
Build an aggregated summary mart for executive reporting.
Snowflake Physical DDL & Schema Deployment
Deploy optimized DDL in Snowflake with proper data types and clustering.
Incremental Mart Loading Strategy
Build incremental loading logic for daily mart refreshes.
Data Quality & Integrity Framework
Enforce rigorous DQ rules across the dimensional model.
Financial Reconciliation Pipeline
Reconcile data mart metrics against trusted Silver source data.
Semantic Views & BI Acceleration
Create user-friendly semantic views for business analysts.
Operational Metadata & Lineage
Track transformation lineage and execution telemetry.
Data Mart Data Dictionary & Documentation
Publish comprehensive documentation for business and analytics engineers.
You are responsible for defining the exact physical schema, surrogate key strategies, and indexing. Ensure your design scales gracefully as transaction volumes grow from millions to billions of rows.
Testing Requirements
Demonstrate dimensional integrity, grain enforcement, financial reconciliation, and query performance.
Required Test Scenarios
Execute the following 12 validation scenarios to verify data mart integrity:
A data mart is only as good as its data integrity. Every metric must be mathematically proven against raw source data.
Acceptance Criteria
Verify that the reporting data mart meets all production acceptance standards.
Definition of Done
The data mart implementation is accepted when all 10 criteria are met:
Sign-off requires reconciliation query outputs proving that total revenue in Snowflake matches the trusted Silver Delta tables.
Developer Deliverables
Provide all models, DDL scripts, transformation pipelines, and validation evidence.
Required Deliverables
The submission must include the following 11 artifacts:
Ensure your DDL and transformation code can be executed cleanly on a fresh Snowflake schema.
Engineering Constraints
Adhere to dimensional modeling best practices and operational standards.
Required Boundaries
The solution must comply with the following 9 engineering constraints:
Mixing grains in fact tables or skipping surrogate key lookups will result in immediate code review failure.
Suggested Project Structure
Recommended repository layout for dimensional data mart engineering.
Recommended Project Layout
Structure your repository to clearly separate DDL schemas, dimension ETL, fact ETL, reconciliation scripts, and tests:
DEV-004-reporting-data-mart/
โ
โโโ README.md
โ
โโโ ddl/
โ โโโ 01_dimensions.sql # DDL for DIM_CUSTOMER, DIM_PRODUCT, DIM_STORE, DIM_DATE
โ โโโ 02_facts.sql # DDL for FACT_SALES and AGG_DAILY_STORE_SALES
โ โโโ 03_semantic_views.sql # Presentation views for BI tools
โ
โโโ src/
โ โโโ staging/
โ โ โโโ stage_entities.py # Extract and deduplicate natural keys
โ โโโ dimensions/
โ โ โโโ dim_customer.py # SCD Type 1 & 2 handler for customers
โ โ โโโ dim_product.py # Product hierarchy and surrogate keys
โ โ โโโ dim_store.py # Store territory mapping
โ โโโ facts/
โ โ โโโ fact_sales.py # Surrogate lookup & measure calculations
โ โ โโโ agg_daily_sales.py # Daily store periodic snapshot mart
โ โโโ reconciliation/
โ โโโ reconcile.py # Automated Silver vs Fact variance checker
โ
โโโ tests/
โ โโโ test_grain_uniqueness.py
โ โโโ test_surrogate_keys.py
โ โโโ test_referential_integrity.py
โ โโโ test_financial_reconciliation.py
โ
โโโ config/
โ โโโ dev.yaml
โ โโโ prod.yaml
โ
โโโ docs/
โโโ data_model.md # Logical and physical star schema design
โโโ data_dictionary.md # Table and metric definitionsModule Responsibilities
Isolating dimension pipelines from fact loading ensures dimensions can be refreshed independently without re-executing expensive fact transformations.
Submission Checklist
Final engineering checklist before submitting DEV-004 for architectural review.
Final Review Checklist
Verify every checklist item before submitting your data mart:
Submit DEV-004 only after the dimensional models, surrogate pipelines, SCD handlers, Snowflake DDL, reconciliation scripts, and test suites have been verified.