DT5: Warehouse foundations

Lesson 2 of 5 · reading 15–25 minutes; practice and project time is on the module page

Layers and schemas

🎯You'll be able to

Organise a warehouse into raw, staging and mart layers in separate schemas, and say what belongs in each.

🏠The everyday picture

A restaurant kitchen has a store room (ingredients as delivered), a prep counter (washed and cut) and the pass (plated dishes). The waiter takes only from the pass.

📘What it really is

📝A worked example

Input: in the solution, cd warehouse and run dbt ls --profiles-dir . (with SABZI_KEY_SALT set).

Expected output: models under sabzisathi.staging (four stg_ models) and sabzisathi.marts (dimensions, the fact table and three marts), plus the tests. Built tables appear in the schemas staging (as views) and marts (as tables).

🌍Where it's used

📝Case scenario

A fintech's analysts built reports straight from staging tables. When a source system renamed a column, 40 reports broke at once. Moving reports to marts, with staging absorbing the rename, meant one model changed and every report kept working.

🖱️Try it

Open the starter's warehouse/models folder and list what's missing compared with this lesson's layers. Success: you notice there's no area history, no tests and that personal data passes straight into a mart.

⚠️Common mistakes

🛠️For your project

Project 3 test 1 builds the dashboard from a copy of the warehouse with every layer but the marts removed.

✅Quick check

What goes in a staging model?

Show the answer

One source table, renamed and tidied, with nothing joined.

Why do dashboards read only from marts?

Show the answer

So source changes are absorbed in earlier layers instead of breaking reports.

← PreviousWhy analysis needs a warehouse
ProLearners Assist