An end-to-end SQL Server data warehouse project that integrates CRM and ERP source data, transforms it through Bronze, Silver, and Gold layers, validates data quality, and produces business-ready analytical models.
The project demonstrates how raw operational data can be transformed into a structured analytics platform using:
- ETL / ELT workflows with stored procedures
- Bronze → Silver → Gold architecture
- Data cleaning and standardization
- Duplicate handling and historical data logic
- Data-quality validation
- Dimensional modeling and star-schema design
- Customer, product, and sales fact modeling
- Reusable Gold-layer views for analytics
The warehouse combines customer, product, category, location, and sales data from CRM and ERP source files.
The pipeline follows:
CRM / ERP Sources
↓
Bronze — Raw Data
↓
Silver — Cleaned & Standardized Data
↓
Gold — Business-Ready Dimensions & Fact
↓
Analytics / Reporting
The final Gold layer provides:
gold.dim_customersgold.dim_productsgold.fact_sales
These models support analysis of sales, customers, products, countries, and other business dimensions.
Stores raw source data with minimal transformation.
- Creates raw warehouse tables
- Loads CRM and ERP CSV files using
BULK INSERT - Refreshes source tables before loading
Cleans, standardizes, and transforms Bronze data.
Examples include:
- Trimming text fields
- Standardizing gender and marital-status values
- Handling missing product costs
- Cleaning customer and location keys
- Converting integer date values into SQL dates
- Validating and correcting sales values
- Removing duplicate customer records with
ROW_NUMBER() - Deriving product validity periods with
LEAD()
Creates business-ready analytical views:
gold.dim_customersgold.dim_productsgold.fact_sales
These views form a dimensional model designed for reporting and analysis.
| Source | Description |
|---|---|
cust_info.csv |
Customer master data |
prd_info.csv |
Product information and product history |
sales_details.csv |
Sales transaction data |
| Source | Description |
|---|---|
CUST_AZ12.csv |
Customer birth date and gender |
LOC_A101.csv |
Customer country/location |
PX_CAT_G1V2.csv |
Product categories and subcategories |
Customer attributes including customer key, ID, name, country, marital status, gender, birthdate, and creation date.
Product attributes including product key, product ID, product name, category, subcategory, cost, product line, and start date.
Historical product versions are filtered so the analytical view represents the current product record.
Transaction-level measures including order number, customer key, product key, order date, shipping date, due date, sales amount, quantity, and price.
- Database and schema creation
- DDL and table design
- Stored procedures
BULK INSERTTRUNCATE TABLEJOINoperationsCASETRIM,REPLACE, andISNULL- Type and date conversion
ROW_NUMBER()LEAD()- Window functions
- Data standardization
- Duplicate handling
- Data-quality validation
- Fact and dimension modeling
- Star-schema design
- ETL / ELT workflow design
TRY...CATCHerror handling
The project checks for:
- Null or duplicate business keys
- Unwanted spaces
- Inconsistent categorical values
- Missing or negative product costs
- Invalid date ranges
- Invalid order, shipping, and due-date relationships
- Sales consistency:
Sales = Quantity × Price - Invalid birth dates
- Country standardization
The project checks for:
- Unique customer surrogate keys
- Unique product surrogate keys
- Connectivity between the fact table and customer/product dimensions
Quality-check scripts:
tests/quality_checks_silver.sql
tests/quality_checks_gold.sql
sql-data-warehouse-project/
│
├── datasets/
│ ├── source_crm/
│ │ ├── cust_info.csv
│ │ ├── prd_info.csv
│ │ └── sales_details.csv
│ │
│ └── source_erp/
│ ├── CUST_AZ12.csv
│ ├── LOC_A101.csv
│ └── PX_CAT_G1V2.csv
│
├── scripts/
│ ├── init_database.sql
│ │
│ ├── bronze/
│ │ ├── ddl_bronze.sql
│ │ └── proc_load_bronze.sql
│ │
│ ├── silver/
│ │ ├── ddl_silver.sql
│ │ └── proc_load_silver.sql
│ │
│ └── gold/
│ └── ddl.gold.sql
│
├── tests/
│ ├── quality_checks_silver.sql
│ └── quality_checks_gold.sql
│
└── LICENSE
- Microsoft SQL Server
- SQL Server Management Studio (SSMS)
The project uses SQL Server-specific features such as BULK INSERT, stored procedures, schemas, and TRY...CATCH.
git clone https://github.com/bhaskar-nb/sql-data-warehouse-project.git
cd sql-data-warehouse-projectRun:
scripts/init_database.sql
This creates the Datawarehouse database and the bronze, silver, and gold schemas.
Warning: The initialization script drops and recreates the database if it already exists.
Run:
scripts/bronze/ddl_bronze.sql
Before loading the Bronze layer, update the machine-specific CSV paths in:
scripts/bronze/proc_load_bronze.sql
Create the procedure and execute:
EXEC bronze.load_bronze;Run:
scripts/silver/ddl_silver.sql
Create and execute:
EXEC silver.load_silver;Run:
scripts/gold/ddl.gold.sql
Execute:
tests/quality_checks_silver.sql
tests/quality_checks_gold.sql
SELECT
SUM(sales_amount) AS total_sales
FROM gold.fact_sales;SELECT
p.category,
p.subcategory,
SUM(f.sales_amount) AS total_sales
FROM gold.fact_sales f
JOIN gold.dim_products p
ON f.product_key = p.product_key
GROUP BY
p.category,
p.subcategory
ORDER BY
total_sales DESC;SELECT
c.country,
SUM(f.sales_amount) AS total_sales
FROM gold.fact_sales f
JOIN gold.dim_customers c
ON f.customer_key = c.customer_key
GROUP BY
c.country
ORDER BY
total_sales DESC;SELECT
c.customer_key,
c.first_name,
c.last_name,
SUM(f.sales_amount) AS total_sales
FROM gold.fact_sales f
JOIN gold.dim_customers c
ON f.customer_key = c.customer_key
GROUP BY
c.customer_key,
c.first_name,
c.last_name
ORDER BY
total_sales DESC;Source CSV Files
↓
Database Initialization
↓
Bronze DDL
↓
Bronze Load Procedure
↓
Silver DDL
↓
Silver ETL / Data Cleaning
↓
Silver Quality Checks
↓
Gold Dimension + Fact Views
↓
Gold Quality Checks
↓
Analytics / Reporting
This project demonstrates how SQL can be used beyond isolated queries to build a structured analytics data pipeline.
Key capabilities include:
- Integrating CRM and ERP source data
- Building repeatable loading procedures
- Applying data cleaning and standardization rules
- Using window functions for deduplication and historical logic
- Designing analytical dimensions and fact tables
- Implementing data-quality checks
- Creating reusable business-ready views
- Preparing a warehouse for downstream reporting and analysis
- Database: Microsoft SQL Server
- IDE: SQL Server Management Studio (SSMS)
- Language: T-SQL
- Data Format: CSV
- Architecture: Bronze / Silver / Gold (Medallion-style)
- Data Model: Dimensional / Star Schema
Bhaskar Nakka
Computer Science Engineering Graduate | Aspiring Data Analyst
Skills demonstrated:
SQL • T-SQL • SQL Server • Data Warehousing • ETL • Data Cleaning • Data Modeling • Data Quality • Window Functions
This project is available under the MIT License. See LICENSE for details.