Post

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

🏒 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

FeatureDatabase (OLTP)Data Warehouse (OLAP)Data LakeData Lakehouse
PurposeDay-to-day operationsAnalytics & ReportingStore everything rawAnalytics on raw + structured
Data TypeStructuredStructuredStructured + Semi + UnstructuredAll types
SchemaSchema-on-WriteSchema-on-WriteSchema-on-ReadSchema-on-Read + Write
Query PatternSimple CRUD (INSERT, UPDATE)Complex aggregations, joinsBatch/ML processingBoth OLAP + ML
UsersApp developers, end usersAnalysts, BI teams, Data EngineersData Scientists, ML EngineersEveryone
ExamplesPostgreSQL, MySQLSnowflake, Redshift, BigQueryS3 + Hive, ADLSDatabricks, Apache Iceberg, Delta Lake
Data VolumeGBsTBs to PBsPBs+PBs+
FreshnessReal-timePeriodic loads (batch/near real-time)Raw ingestionNear 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”)

PropertyMeaningExample
Subject-OrientedOrganized by business subjects, not applicationsβ€œSales,” β€œCustomers,” β€œProducts” β€” not β€œApp1_DB,” β€œApp2_DB”
IntegratedData from multiple sources is cleaned & unifiedCustomer from CRM + ERP + Website β†’ single customer view
Non-VolatileOnce loaded, data is not frequently changed/deletedHistorical records are preserved for trend analysis
Time-VariantData is stored with a time dimensionYou 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

LayerWhat Happens Here
Staging AreaRaw data lands here first; temporary; cleansing & deduplication
Core Warehouse (ODS/DWH)Clean, integrated, modeled data (facts + dimensions)
Data MartsSubset 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)
AspectETLELT
Transform LocationOutside DWH (ETL server)Inside DWH (uses DWH compute)
SpeedSlower (separate processing)Faster (leverages DWH power)
Best ForOn-premise, smaller dataCloud DWH (Snowflake, BigQuery)
ToolsInformatica, Talend, SSISdbt, Snowflake SQL, Spark
CostSeparate infra neededPay 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

AspectStar SchemaSnowflake Schema
Dimension TablesDenormalized (flat)Normalized (hierarchical)
Query Performance⚑ Faster (fewer joins)🐒 Slower (more joins)
StorageMore (redundant data)Less (no redundancy)
ComplexitySimpleMore complex
Best ForBI/Reporting, most DWHVery large dimensions, strict storage needs
Industry Preferenceβœ… Most commonLess common

πŸ—„οΈ Data Vault 2.0

For enterprise-scale, audit-heavy environments

ComponentPurposeExample
HubBusiness keys (unique identifiers)hub_customer β†’ customer_bk
LinkRelationships between hubslink_customer_order
SatelliteDescriptive attributes + historysat_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

TypeWhat it CapturesExampleGrain
Transaction FactOne row per eventEach sale, each clickIndividual event
Periodic SnapshotState at regular intervalsMonthly account balance, daily inventoryOne row per period
Accumulating SnapshotLifecycle of a processOrder lifecycle (placed β†’ shipped β†’ delivered)One row per entity, updated over time
Factless FactEvents with no measuresStudent attended class (just FKs, no metrics)Event occurrence

8. Slowly Changing Dimensions (SCD)

Mnemonic: β€œHow do you handle change?”

SCD TypeStrategyExampleProsCons
Type 0No change everDate of birthSimpleNo history
Type 1Overwrite old valueUpdate address directlySimple, current data❌ Loses history
Type 2Add new row with versioningNew row with start_date, end_date, is_currentβœ… Full historyTable grows large
Type 3Add new columncurrent_city, previous_cityLimited historyOnly 1 level of history
Type 4Separate history tableCurrent in main, history in another tableClean separationMore complexity
Type 6Hybrid (1 + 2 + 3)Combines overwrite + new row + extra columnsFlexibleComplex 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

TypeCan Sum Across All Dimensions?Example
Additiveβœ… YesRevenue, Quantity
Semi-Additive⚠️ Some dimensions onlyAccount Balance (sum across customers, NOT across time)
Non-Additive❌ NoRatios, Percentages, Unit Price

10. Modern Data Warehouse Platforms

PlatformProviderKey Strength
SnowflakeIndependentSeparation of storage & compute, auto-scaling
BigQueryGoogle CloudServerless, great for petabyte-scale analytics
RedshiftAWSDeep AWS integration, Spectrum for data lake queries
Azure SynapseMicrosoftUnified analytics, integrates with Power BI
Databricks SQLDatabricksLakehouse 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

AspectBill Inmon (Top-Down)Ralph Kimball (Bottom-Up)
ApproachBuild enterprise DWH first β†’ then data martsBuild data marts first β†’ integrate into DWH
Schema3NF (Normalized)Star Schema (Denormalized)
Time to ValueSlower (big upfront investment)Faster (iterative delivery)
ComplexityHigher initial complexitySimpler to start
Best ForLarge enterprises with clear data strategyAgile teams, business-driven analytics
Modern TrendLess 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
1What is a Data Warehouse and why do we need one?
2Explain Star Schema vs Snowflake Schema with examples
3What are Fact tables and Dimension tables?
4Explain SCD Types 1, 2, and 3 with SQL examples
5What is the grain of a fact table and why does it matter?
6ETL vs ELT β€” when would you choose each?
7Inmon vs Kimball approach?
8What are additive, semi-additive, and non-additive facts?
9How do you handle late-arriving facts/dimensions?
10What is a Data Mart vs Data Warehouse?
11Explain Data Vault modeling
12How do you optimize query performance in a DWH?
13What is a surrogate key and why use it?
14Explain partitioning and clustering in Snowflake/BigQuery
15What 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!

This post is licensed under CC BY 4.0 by the author.