|
1 | 1 | # SQL Data Warehouse Project |
2 | 2 |
|
3 | | -**Live project link: https://sentongo-web.github.io/SQL_datawarehouse_Project/** |
| 3 | +[Live Project Link](https://sentongo-web.github.io/SQL_datawarehouse_Project/) |
4 | 4 |
|
5 | | -A SQL Server data warehouse built from scratch on top of raw CRM and ERP exports. I built this as a portfolio project to show what I can actually do with SQL — not a toy exercise, but a full pipeline: raw ingestion, cleansing and standardization, a proper dimensional model, data quality tests, and analytics on top, all in T-SQL. |
| 5 | +A SQL Server data warehouse built from raw CRM and ERP exports. This project covers the full ETL pipeline using T-SQL: raw data ingestion, cleansing and standardization, dimensional modeling, automated quality checks, and reporting views. |
6 | 6 |
|
7 | | -## The problem this solves |
| 7 | +## The Problem |
8 | 8 |
|
9 | | -Imagine a company running two systems that never talk to each other: a CRM for customers and sales, and an ERP for products and locations. Each one exports its own CSV files, using its own keys, its own codes, its own idea of what a clean record looks like. Before anyone can build a dashboard on this data, someone has to reconcile it. |
| 9 | +Imagine a company running two siloed systems: a CRM handling customer profiles and sales transactions, and an ERP tracking products and store locations. Each system exports separate CSV files with inconsistent keys, localized status codes, and formatting discrepancies. |
10 | 10 |
|
11 | | -That's what this warehouse does. It pulls the raw files in as-is, cleans and standardizes them, resolves the mismatches between the two systems, and lands everything in a star schema that's ready to query directly — no knowledge of the mess underneath required. |
| 11 | +Before building downstream reporting or analytics dashboards, these sources must be reconciled. This project ingests the raw exports, cleans and standardizes the records, resolves cross-system mismatches, and outputs a clean star schema ready for querying. |
12 | 12 |
|
13 | 13 | ## Architecture |
14 | 14 |
|
15 | | -The warehouse follows a Medallion (Bronze / Silver / Gold) architecture: |
| 15 | +The warehouse uses a Medallion (Bronze, Silver, Gold) architecture: |
16 | 16 |
|
17 | 17 |  |
18 | 18 |
|
19 | | -- **Bronze** — raw data loaded as-is from the source CSV files via `BULK INSERT`, no transformation. This is the audit trail. |
20 | | -- **Silver** — cleansed, deduplicated, and standardized. Dates get parsed safely, codes get expanded into readable values, and sales figures that don't add up get recalculated from what's trustworthy. The whole load runs in one transaction, so a failure rolls everything back instead of leaving some tables refreshed and others stale. |
21 | | -- **Gold** — business-ready views modeled as a star schema: two dimensions and one fact table, plus two reporting views built specifically for customer and product analysis. |
| 19 | +* **Bronze (Raw Load):** Ingests CSV files as-is into staging tables using `BULK INSERT` to maintain a full audit trail. |
| 20 | +* **Silver (Cleansing & Transformation):** Handles data hygiene, safe date parsing, code expansion, and sales value reconciliations. The Silver layer load runs within an explicit transaction to ensure atomic processing and prevent partial loads. |
| 21 | +* **Gold (Business Layer):** Exposes clean views structured as a star schema, including dimension tables, a fact table, and specialized reporting views for customer and product analytics. |
22 | 22 |
|
23 | | -## Data model |
| 23 | +## Data Model |
24 | 24 |
|
25 | | -`gold.fact_sales` sits at the center, at a grain of one row per sales order line, joined to `gold.dim_customers` and `gold.dim_products`. |
| 25 | +The Gold layer uses a star schema structure centered around transactions: |
26 | 26 |
|
27 | | - |
| 27 | +* `gold.fact_sales` – Core transaction records containing order details, quantities, line items, and monetary totals. |
| 28 | +* `gold.dim_customers` – Unified customer records joining demographic data from the CRM with location data from the ERP. |
| 29 | +* `gold.dim_products` – Product catalog with hierarchy, pricing history, and supplier metadata. |
28 | 30 |
|
29 | | -The full reasoning behind the model — why a star schema, the grain, the key strategy, and how missing dimension matches are handled — is written up in [`docs/data_model.md`](docs/data_model.md). Column-level definitions for every Gold table are in [`docs/data_catalog.md`](docs/data_catalog.md). |
| 31 | +Additionally, two aggregated reporting views support direct business intelligence tasks: |
30 | 32 |
|
31 | | -## Repository structure |
| 33 | +* `gold.report_customer_metrics` – Customer lifetime value, purchase frequency, and recency analysis. |
| 34 | +* `gold.report_product_performance` – Sales volume, margin analysis, and category-level rollups. |
32 | 35 |
|
33 | | -```text |
34 | | -SQL_datawarehouse_Project/ |
35 | | -├── datasets/ Raw CRM and ERP CSV exports |
36 | | -├── docs/ |
37 | | -│ ├── data_catalog.md Column-level reference for the Gold layer |
38 | | -│ ├── data_model.md Data modeling design decisions |
39 | | -│ ├── naming_conventions.md Naming rules for schemas, tables and columns |
40 | | -│ ├── model_images/ Architecture and data model diagrams |
41 | | -│ ├── layer_explanation/ Medallion layer explanation (PDF) |
42 | | -│ └── Practice/ Standalone SQL practice scripts (joins, set operators, etc.) |
43 | | -├── scripts/ |
44 | | -│ ├── init_database.sql Creates the DataWarehouse database and schemas |
45 | | -│ ├── bronze_layer/ Bronze DDL, load procedure, and exploratory checks |
46 | | -│ ├── silver_layer/ Silver DDL and the load_silver procedure |
47 | | -│ └── gold_layer/ Gold views (star schema) and view-confirmation queries |
48 | | -├── exploratory data analysis/ Runnable analysis scripts: trends, rankings, segmentation, |
49 | | -│ cumulative and part-to-whole analysis, customer/product reports |
50 | | -├── tests/ Data quality and referential-integrity checks |
51 | | -├── index.html, assets/ The landing page for paulsentongo.dev |
52 | | -├── CNAME Custom domain for GitHub Pages |
53 | | -└── LICENSE |
54 | | -``` |
| 36 | +## Setup & Execution |
55 | 37 |
|
56 | | -## Tech stack |
57 | | - |
58 | | -- **Microsoft SQL Server** — the database engine |
59 | | -- **T-SQL** — every transformation, all the way through; no external ETL tool |
60 | | -- **SQL Server Management Studio** — for development and testing |
61 | | -- **Git / GitHub** — version control and hosting |
62 | | -- **Plain HTML, CSS and JavaScript** — the landing page, no framework or build step |
63 | | - |
64 | | -## Running it yourself |
65 | | - |
66 | | -1. Run [`scripts/init_database.sql`](scripts/init_database.sql) to create the `DataWarehouse` database and the `bronze` / `silver` / `gold` schemas. This drops and recreates the database if it already exists — read the warning at the top of the script first. |
67 | | -2. Run the DDL and load procedure for each layer, in order: |
68 | | - - [`scripts/bronze_layer/ddl_bronze_layer.sql`](scripts/bronze_layer/ddl_bronze_layer.sql) then [`scripts/bronze_layer/proc_load_bronze.sql`](scripts/bronze_layer/proc_load_bronze.sql) |
69 | | - - [`scripts/silver_layer/ddl_silver.sql`](scripts/silver_layer/ddl_silver.sql) then [`scripts/silver_layer/load_silver_layer.sql`](scripts/silver_layer/load_silver_layer.sql) |
70 | | - - [`scripts/gold_layer/ddl_gold.sql`](scripts/gold_layer/ddl_gold.sql) |
71 | | -3. Before step 2's Bronze load, open `proc_load_bronze.sql` and update the six `BULK INSERT` file paths to wherever you've cloned this repo — `BULK INSERT` reads from the SQL Server host's own file system, not from wherever you're running the script. |
72 | | -4. Run the checks in [`tests/silver_layer_checks.sql`](tests/silver_layer_checks.sql) and [`tests/gold_checks.sql`](tests/gold_checks.sql) to confirm the load is clean. |
73 | | -5. From there, everything in [`exploratory data analysis/`](exploratory%20data%20analysis/) runs directly against the Gold views. |
74 | | - |
75 | | -## Analytics on top of the model |
76 | | - |
77 | | -The `exploratory data analysis/` folder covers change-over-time trends, cumulative and moving totals, year-over-year performance, part-to-whole contribution by category, magnitude and ranking analysis, and customer/product segmentation — plus two standing reporting views, `gold.report_customers` and `gold.report_products`, that consolidate recency, lifetime value and segment for every customer and product. |
78 | | - |
79 | | -## Contact |
80 | | - |
81 | | -**Paul Sentongo** |
82 | | -[Project Link(https://sentongo-web.github.io/SQL_datawarehouse_Project/#explore) · [sentongopol@gmail.com](mailto:sentongopol@gmail.com) · [LinkedIn](https://www.linkedin.com/in/paul-sentongo-885041284/) |
83 | | - |
84 | | -## License |
85 | | - |
86 | | -[MIT](LICENSE) |
| 38 | +1. Clone this repository. |
| 39 | +2. Run `scripts/bronze/proc_load_bronze.sql` to initialize staging tables and load raw CSVs. |
| 40 | +3. Execute `scripts/silver/proc_load_silver.sql` to transform, clean, and validate records into the Silver layer. |
| 41 | +4. Run `scripts/gold/ddl_gold.sql` to build the star schema views and analytical layers. |
| 42 | +5. Execute tests in `tests/quality_checks.sql` to confirm data integrity across layers. |
0 commit comments