Data Warehousing
Operational databases are tuned for many small transactions. A warehouse is tuned for large analytical questions over history.
In plain English
A report card for the whole school, built from many teachers' grade books.
The one idea
A warehouse integrates subject-oriented, time-variant, nonvolatile data for analysis, separate from the operational database.
Analysts need history and broad scans. Operational systems need short, concurrent writes. Putting both on one schema makes both worse.
By the end
- 01Distinguish OLTP from OLAP.
- 02Explain the ETL pipeline.
- 03Describe star and snowflake schemas.
- 04Know what a data mart is.
OLTP versus OLAP
OLTP systems handle many short reads and writes: place an order, update a balance. OLAP systems run fewer, larger analytical queries over historical data: revenue by region by quarter. Mixing the two on one system usually hurts both.
ETL and schemas
Extract, transform, and load (ETL) moves data from operational systems into the warehouse. The transformation cleans, conforms, and aggregates. A star schema has a central fact table surrounded by dimension tables. A snowflake schema normalizes dimensions further, reducing redundancy but adding joins.
star:
FactSales(date_id, product_id, store_id, amount)
DimDate, DimProduct, DimStore
snowflake:
DimProduct -> DimCategory -> DimDepartmentOLAP and data marts
OLAP operations include roll-up, drill-down, slice, dice, and pivot. A data mart is a smaller warehouse focused on one department or subject. It can be independent or fed from the central warehouse.
From nightly orders to a quarterly report
An OLTP system records orders. Finance wants revenue by product and quarter without slowing checkout.
Extract new orders and load a staging area.
The operational database is not queried by the reporting job.
Transform into a star schema: fact_sales, dim_date, dim_product.
The warehouse stores historical facts with conformed dimensions.
Aggregate by quarter and product.
The report scans a controlled analytical schema, not the checkout tables.
ConclusionETL is not a copy job. It is a modeling job that turns operational events into analytical facts.
The trade-off
No free correctness.
Gain
Historical analysis without competing with transactions.
Cost
ETL latency, extra storage, and a second schema that must be governed.
Verdict
Separate analytical workloads once reporting starts competing with operational latency.
Recap
What to keep.
Takeaways
- +OLTP optimizes transactions; OLAP optimizes analysis.
- +ETL extracts, transforms, and loads warehouse data.
- +Star schemas use a fact table and denormalized dimensions.
- +Snowflake schemas normalize dimensions further.
- +Data marts serve a focused subset of the warehouse.
Traps
- !Running heavy analytics on the production OLTP database.
- !Assuming a star schema is always better than snowflake.
- !Skipping data quality in the transform step.
Focus
- →Compare OLTP and OLAP workloads.
- →Draw a small star schema.
- →Explain roll-up and drill-down.
Check yourself
Before you turn the page.
What does ETL stand for?
What is the center of a star schema?