Data Warehousing Complete Guide for Data Engineers
A complete data warehousing guide for data engineers covering architecture, ETL vs ELT, schema design, BigQuery, and modern warehouse best practices.
π’ Data Warehousing β Complete Guide for Data Engineers
1. What is a Data Warehouse?
A Data Warehouse (DWH) is a centralized repository that stores large volumes of structured, historical data from multiple sources, optimized for analytical queries and reporting.
Simple Analogy: If databases are like individual shop registers, a data warehouse is like the companyβs central accounting office β it collects all data, organizes it, and helps leadership make decisions.
2. Data Warehouse vs Database vs Data Lake vs Data Lakehouse
| Feature | Database (OLTP) | Data Warehouse (OLAP) | Data Lake | Data Lakehouse |
|---|---|---|---|---|
| Purpose | Day-to-day operations | Analytics & Reporting | Store everything raw | Analytics on raw + structured |
| Data Type | Structured | Structured | Structured + Semi + Unstructured | All types |
| Schema | Schema-on-Write | Schema-on-Write | Schema-on-Read | Schema-on-Read + Write |
| Query Pattern | Simple CRUD (INSERT, UPDATE) | Complex aggregations, joins | Batch/ML processing | Both OLAP + ML |
| Users | App developers, end users | Analysts, BI teams, Data Engineers | Data Scientists, ML Engineers | Everyone |
| Examples | PostgreSQL, MySQL | Snowflake, Redshift, BigQuery | S3 + Hive, ADLS | Databricks, Apache Iceberg, Delta Lake |
| Data Volume | GBs | TBs to PBs | PBs+ | PBs+ |
| Freshness | Real-time | Periodic loads (batch/near real-time) | Raw ingestion | Near real-time |
π― Interview Tip: Always be ready to explain why a company needs a DWH when they already have databases. Answer: βOperational databases arenβt designed for heavy analytical queries β running reports on them would slow down the application.β
3. Core Characteristics of a Data Warehouse
Mnemonic: βSINTβ β Subject-oriented, Integrated, Non-volatile, Time-variant (coined by Bill Inmon, the βFather of Data Warehousingβ)
| Property | Meaning | Example |
|---|---|---|
| Subject-Oriented | Organized by business subjects, not applications | βSales,β βCustomers,β βProductsβ β not βApp1_DB,β βApp2_DBβ |
| Integrated | Data from multiple sources is cleaned & unified | Customer from CRM + ERP + Website β single customer view |
| Non-Volatile | Once loaded, data is not frequently changed/deleted | Historical records are preserved for trend analysis |
| Time-Variant | Data is stored with a time dimension | You can query sales for Q1 2024 vs Q1 2025 |
4. Data Warehouse Architecture
πΉ The Classic 3-Tier Architecture
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TIER 3: FRONT END β
β BI Tools / Dashboards / Reports / Ad-hoc Queries β
β (Tableau, Power BI, Looker, Metabase, Superset) β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β SQL / ODBC / API
ββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββ
β TIER 2: DATA WAREHOUSE β
β β
β ββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ β
β β Staging βββββΆβ Core Warehouse βββββΆβ Data Marts β β
β β Area β β (Fact + Dims) β β (Sales, Finance) β β
β ββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ β
β β
ββββββββββββββββββββββββββββ²βββββββββββββββββββββββββββββββββββββββ
β ETL / ELT
ββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββ
β TIER 1: DATA SOURCES β
β CRM | ERP | Flat Files | APIs | Logs | IoT β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Key Layers Explained
| Layer | What Happens Here |
|---|---|
| Staging Area | Raw data lands here first; temporary; cleansing & deduplication |
| Core Warehouse (ODS/DWH) | Clean, integrated, modeled data (facts + dimensions) |
| Data Marts | Subset of DWH for specific departments (Sales Mart, Finance Mart) |
5. ETL vs ELT
Mnemonic: βWhere does **Transformation happen?β**
1
2
ETL: Source β [Transform] β Load into DWH (Traditional)
ELT: Source β Load into DWH β [Transform] (Modern/Cloud)
| Aspect | ETL | ELT |
|---|---|---|
| Transform Location | Outside DWH (ETL server) | Inside DWH (uses DWH compute) |
| Speed | Slower (separate processing) | Faster (leverages DWH power) |
| Best For | On-premise, smaller data | Cloud DWH (Snowflake, BigQuery) |
| Tools | Informatica, Talend, SSIS | dbt, Snowflake SQL, Spark |
| Cost | Separate infra needed | Pay for DWH compute |
π― Modern Trend: ELT is dominant in cloud-native warehouses. dbt (data build tool) has become the industry standard for the βTβ in ELT.
6. Schema Design Patterns (The Heart of DWH)
β Star Schema
Most common. Easy to understand. Fast queries.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
ββββββββββββββββ
β dim_product β
ββββββββββββββββ
β product_id β
β product_name β
β category β
ββββββββ¬ββββββββ
β
ββββββββββββββββ ββββββββΌββββββββββββ ββββββββββββββββ
β dim_customer β β fact_sales β β dim_date β
ββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββ
β customer_id βββββ customer_id (FK) β β date_id β
β name β β product_id (FK) ββββΆβ date β
β city β β date_id (FK) β β month β
ββββββββββββββββ β store_id (FK) β β quarter β
ββββββββββββββββββββ β year β
β quantity β ββββββββββββββββ
β revenue β
β discount β ββββββββββββββββ
ββββββββ¬ββββββββββββ β dim_store β
β ββββββββββββββββ
ββββββββββββββββΆβ store_id β
β store_name β
β region β
ββββββββββββββββ
Characteristics:
- Fact Table (center) = Measurable events (sales, clicks, transactions)
- Dimension Tables (points of the star) = Descriptive context (who, what, when, where)
- Denormalized dimensions β fewer JOINs β fast queries
βοΈ Snowflake Schema
Normalized dimensions β dimensions have sub-dimensions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
ββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β dim_city ββββββ dim_customer ββββββ fact_sales β
ββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β city_id β β customer_id β β customer_id β
β city_name β β name β β product_id β
β state_id ββββΆ β city_id (FK) β β revenue β
ββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β
βΌ
ββββββββββββββ
β dim_state β
ββββββββββββββ
β state_id β
β state_name β
β country β
ββββββββββββββ
Characteristics:
- Dimensions are normalized (broken into sub-tables)
- Saves storage, reduces redundancy
- More JOINs β slightly slower queries
- Used when dimension tables are very large
ποΈ Star vs Snowflake β Quick Comparison
| Aspect | Star Schema | Snowflake Schema |
|---|---|---|
| Dimension Tables | Denormalized (flat) | Normalized (hierarchical) |
| Query Performance | β‘ Faster (fewer joins) | π’ Slower (more joins) |
| Storage | More (redundant data) | Less (no redundancy) |
| Complexity | Simple | More complex |
| Best For | BI/Reporting, most DWH | Very large dimensions, strict storage needs |
| Industry Preference | β Most common | Less common |
ποΈ Data Vault 2.0
For enterprise-scale, audit-heavy environments
| Component | Purpose | Example |
|---|---|---|
| Hub | Business keys (unique identifiers) | hub_customer β customer_bk |
| Link | Relationships between hubs | link_customer_order |
| Satellite | Descriptive attributes + history | sat_customer_details (name, address, load_date) |
When to use: Large enterprises needing full audit trails, parallel loading, and agility.
7. Fact Table Types
Mnemonic: βTASβ β Transaction, Accumulating, Snapshot
| Type | What it Captures | Example | Grain |
|---|---|---|---|
| Transaction Fact | One row per event | Each sale, each click | Individual event |
| Periodic Snapshot | State at regular intervals | Monthly account balance, daily inventory | One row per period |
| Accumulating Snapshot | Lifecycle of a process | Order lifecycle (placed β shipped β delivered) | One row per entity, updated over time |
| Factless Fact | Events with no measures | Student attended class (just FKs, no metrics) | Event occurrence |
8. Slowly Changing Dimensions (SCD)
Mnemonic: βHow do you handle change?β
| SCD Type | Strategy | Example | Pros | Cons |
|---|---|---|---|---|
| Type 0 | No change ever | Date of birth | Simple | No history |
| Type 1 | Overwrite old value | Update address directly | Simple, current data | β Loses history |
| Type 2 | Add new row with versioning | New row with start_date, end_date, is_current | β Full history | Table grows large |
| Type 3 | Add new column | current_city, previous_city | Limited history | Only 1 level of history |
| Type 4 | Separate history table | Current in main, history in another table | Clean separation | More complexity |
| Type 6 | Hybrid (1 + 2 + 3) | Combines overwrite + new row + extra columns | Flexible | Complex to implement |
π― Interview Favorite: SCD Type 2 is the most commonly asked. Be ready to write SQL that implements it.
9. Key Measures & Concepts
Grain
βWhat does one row in the fact table represent?β
This is the most important decision in DWH design.
- β βOne row per transaction per product per store per dayβ
- β Vague grain β broken reports
Additive vs Non-Additive Measures
| Type | Can Sum Across All Dimensions? | Example |
|---|---|---|
| Additive | β Yes | Revenue, Quantity |
| Semi-Additive | β οΈ Some dimensions only | Account Balance (sum across customers, NOT across time) |
| Non-Additive | β No | Ratios, Percentages, Unit Price |
10. Modern Data Warehouse Platforms
| Platform | Provider | Key Strength |
|---|---|---|
| Snowflake | Independent | Separation of storage & compute, auto-scaling |
| BigQuery | Google Cloud | Serverless, great for petabyte-scale analytics |
| Redshift | AWS | Deep AWS integration, Spectrum for data lake queries |
| Azure Synapse | Microsoft | Unified analytics, integrates with Power BI |
| Databricks SQL | Databricks | Lakehouse pattern, Delta Lake, Spark-powered |
11. Important Design Principles
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
ββββββββββββββββββββββββββββββββββββββββββββββββββ
β DATA WAREHOUSE DESIGN RULES β
ββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 1. Define the GRAIN first β
β 2. Choose dimensions before facts β
β 3. Use surrogate keys (not business keys) in β
β fact tables β
β 4. Prefer Star Schema unless you have a reason β
β not to β
β 5. Make dimensions wide (many columns) and β
β facts tall (many rows) β
β 6. Handle NULLs with "Unknown" dimension rows β
β 7. Design for query patterns, not source β
β systems β
β 8. Implement SCD Type 2 for critical β
β dimensions β
β 9. Partition fact tables by date β
β10. Document everything β lineage matters β
ββββββββββββββββββββββββββββββββββββββββββββββββββ
12. Inmon vs Kimball β The Two Schools of Thought
| Aspect | Bill Inmon (Top-Down) | Ralph Kimball (Bottom-Up) |
|---|---|---|
| Approach | Build enterprise DWH first β then data marts | Build data marts first β integrate into DWH |
| Schema | 3NF (Normalized) | Star Schema (Denormalized) |
| Time to Value | Slower (big upfront investment) | Faster (iterative delivery) |
| Complexity | Higher initial complexity | Simpler to start |
| Best For | Large enterprises with clear data strategy | Agile teams, business-driven analytics |
| Modern Trend | Less common standalone | β More widely adopted |
π― Interview Answer: βMost modern cloud warehouses follow Kimballβs dimensional modeling approach with Star Schemas, because itβs optimized for analytical query patterns and BI tool compatibility.β
13. π― Interview Questions to Prepare
| # | Question |
|---|---|
| 1 | What is a Data Warehouse and why do we need one? |
| 2 | Explain Star Schema vs Snowflake Schema with examples |
| 3 | What are Fact tables and Dimension tables? |
| 4 | Explain SCD Types 1, 2, and 3 with SQL examples |
| 5 | What is the grain of a fact table and why does it matter? |
| 6 | ETL vs ELT β when would you choose each? |
| 7 | Inmon vs Kimball approach? |
| 8 | What are additive, semi-additive, and non-additive facts? |
| 9 | How do you handle late-arriving facts/dimensions? |
| 10 | What is a Data Mart vs Data Warehouse? |
| 11 | Explain Data Vault modeling |
| 12 | How do you optimize query performance in a DWH? |
| 13 | What is a surrogate key and why use it? |
| 14 | Explain partitioning and clustering in Snowflake/BigQuery |
| 15 | What is a Junk Dimension? Degenerate Dimension? Role-Playing Dimension? |
14. π‘ Quick-Reference Cheat Sheet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DWH CHEAT SHEET β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β OLTP = Operations | OLAP = Analytics β
β Fact = Measures (numbers) | Dim = Context (who/what) β
β Star = Denormalized dims | Snowflake = Normalized β
β SCD2 = Full history (most used) β
β Grain = What 1 row represents β
β Surrogate Key = System-generated (not business key) β
β ETL = Transform outside DWH | ELT = Transform inside β
β Kimball = Star + Bottom-up | Inmon = 3NF + Top-down β
β Partition by DATE | Cluster by HIGH-CARDINALITY cols β
β dbt = Modern "T" in ELT β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Final Tip: Data warehousing interviews test your ability to design, not just define. Practice drawing schemas on a whiteboard, writing SCD Type 2 SQL, and explaining trade-offs for every design decision you make. Good luck!
