Sunday , November 29 2026
Data warehouse basics: OLTP vs OLAP, fact and dimension tables, star and snowflake schemas, SCDs and cloud warehouses.

Data Warehousing: OLAP, Star Schema and Cloud Warehouses

Updated: 28 November 2026Level: IntermediateReading time: about 9 minutesSQL · concepts

A data warehouse is a central database designed for analysis, not for running an app. It collects cleaned data from many systems – sales, website, CRM, finance – so the business can answer questions with SQL and dashboards.

What You Will Learn

  • OLTP vs OLAP
  • Fact and dimension tables
  • Star and snowflake schemas
  • Slowly changing dimensions
  • Popular cloud warehouses

Prerequisites

Database Design.

OLTP vs OLAP

OLTP (app database) OLAP (warehouse)
Purpose Run the business: place orders Analyse the business: sales by month
Queries Many small reads/writes Few large scans and aggregations
Design Normalized Denormalized star schema
Examples MySQL, PostgreSQL BigQuery, Snowflake, Redshift, Synapse

Star Schema

A fact table stores measurable events (each sale) with keys to dimension tables that describe them (date, product, store, customer).

Example
CREATE TABLE dim_date    (date_key INT PRIMARY KEY, full_date DATE, month INT, year INT);
CREATE TABLE dim_product (product_key INT PRIMARY KEY, name TEXT, category TEXT);
CREATE TABLE dim_store   (store_key INT PRIMARY KEY, city TEXT, state TEXT);

CREATE TABLE fact_sales (
  date_key    INT REFERENCES dim_date(date_key),
  product_key INT REFERENCES dim_product(product_key),
  store_key   INT REFERENCES dim_store(store_key),
  quantity    INT,
  amount      DECIMAL(10,2)
);
Typical report query
SELECT d.year, d.month, p.category, s.city, SUM(f.amount) AS revenue
FROM fact_sales f
JOIN dim_date d    ON d.date_key = f.date_key
JOIN dim_product p ON p.product_key = f.product_key
JOIN dim_store s   ON s.store_key = f.store_key
GROUP BY d.year, d.month, p.category, s.city;

Explanation: Analysts can slice the same facts by any dimension. In a snowflake schema, dimensions are further normalized (e.g. category in its own table) – saving space but needing more joins.

Slowly Changing Dimensions (SCD)

Type When a customer moves city…
Type 1 Overwrite the old city (no history)
Type 2 Add a new row with valid_from / valid_to dates (full history)
Type 3 Keep a “previous_city” column (limited history)

Cloud Warehouses

Warehouse Notes
Google BigQuery Serverless, pay per query; BigQuery ML
Snowflake Runs on AWS, Azure or GCP; separate storage and compute
Amazon Redshift AWS warehouse
Azure Synapse / Microsoft Fabric Microsoft analytics platform
Databricks SQL Warehouse on a lakehouse (see Data Lakes)

Series

Data Engineering series: ETL Pipelines · Apache Spark · Apache Kafka · Apache Airflow · Data Warehousing · Data Lakes · Big Data Analytics

Interview Questions

Q: Fact vs dimension table?
Facts hold measurable events and foreign keys; dimensions hold descriptive attributes.

Q: Why denormalize a warehouse?
Fewer joins make large analytical queries simpler and faster.

Practice Exercises

  1. Design a star schema for a college: fact_attendance with student, course and date dimensions.
  2. Write a query for monthly revenue by product category.

Summary

A data warehouse is an analytics database. Star schemas with fact and dimension tables, and SCDs for history, make reporting fast and consistent.

Next: Data Lakes · SQL for Analytics

About Machine Learning

Check Also

Apache Kafka Tutorial with Python: Real-Time Data Streaming

Kafka concepts, running Kafka with Docker, Python producer and consumer, consumer groups, offsets and real-time ML uses.