Staging, Warehouse and Mart: Why Three Layers

A report starts reading the import table because it is already there. Staging, warehouse and mart are three layers that prevent that shortcut from becoming the data architecture. Each layer answers a different question about raw input, trusted history, and ready-to-use metrics.

A restaurant kitchen with crates of raw vegetables at the back, prepped bowls in the middle and finished plates at the pass.

Use Staging to Receive Data

Staging holds data close to source form while a load validates it. Keep source file identity, arrival time, batch ID, and raw values when they help diagnose rejects. Staging can be truncated or partitioned by run according to restart needs. It should not be the final contract for a dashboard.

I keep bad rows for review instead of forcing every value into a clean target. A report that queries staging can change when a file is partially loaded. The receiving dock is a poor dining room, even when the boxes are arranged neatly.

Use the Warehouse for Trusted History

The warehouse stores integrated, validated data with stable keys and defined history. It resolves source codes, duplicates, and effective dates. Facts and dimensions support consistent joins across reporting needs. This layer should explain where a number came from and how it changed over time.

I ask whether the same customer means the same thing in every report. If not, the warehouse has not finished its job. A table can be large and still not be a warehouse if nobody owns its definitions.

Use a Mart for Focused Questions

A mart narrows warehouse data for a team or use case. It can contain summaries, subject-specific dimensions, and simpler access rules. A sales dashboard should not scan every transaction and every unrelated dimension to display a weekly trend. A mart can make that query cheaper and the metric definition clearer.

A mart is not a private copy of any source table someone happens to like. I define its refresh, grain, owner, and reconciliation to warehouse totals. Without those, several marts can become competing versions of truth.

Show the Staging, Warehouse and Mart Boundaries

A simple SQL inventory helps make the current layout visible. Schemas can represent layers inside one database, though larger systems can use separate databases. The query lists tables by schema. Names alone do not prove quality, but they reveal where raw and curated objects live.

I follow the output with a data-flow diagram and one sample metric. The useful question is whether each transformation has a clear place and test.

SELECT s.name AS schema_name,
       t.name AS table_name,
       t.create_date
FROM sys.tables AS t
JOIN sys.schemas AS s ON s.schema_id = t.schema_id
WHERE s.name IN (N'stg', N'dw', N'mart')
ORDER BY s.name, t.name;
Three layers, three different questions: a diagram about the staging, warehouse and mart

Keep Grain Explicit Across Staging, Warehouse and Mart

A staging row can represent a file record. A warehouse fact can represent one order line. A mart row can represent daily sales by region. These grains are different. Mixing them without documentation causes duplicated totals and confusing joins. Write the grain in the table design and in the report definition.

I test a total at each transition. If ten order lines become one daily row, the aggregation should preserve the intended amount and count. The exact numeric result comes from your own query and data, not from a design diagram.

Validate Staging, Warehouse and Mart Data Before Promotion

Staging validation can reject invalid dates, missing keys, and duplicate source records. Warehouse loading applies business rules and records lineage. Mart refresh checks that its totals reconcile with trusted warehouse data. A failed check should stop promotion and alert an owner rather than publish partial data.

This query illustrates a reconciliation by date between a fact table and a daily mart. Adapt names and amount rules to your model. A mismatch deserves investigation before the dashboard refresh is called successful.

SELECT COALESCE(f.OrderDate, m.OrderDate) AS OrderDate,
       f.TotalAmount AS fact_amount,
       m.TotalAmount AS mart_amount
FROM (SELECT OrderDate, SUM(Amount) AS TotalAmount
      FROM dw.FactOrder
      GROUP BY OrderDate) AS f
FULL JOIN mart.DailySales AS m
  ON m.OrderDate = f.OrderDate
WHERE ISNULL(f.TotalAmount, 0)
   <> ISNULL(m.TotalAmount, 0);

Do Not Multiply Copies Without Purpose

Staging, warehouse and mart do not mean every column must be copied three times. Small teams can use views or simple tables for some boundaries. The point is separating raw ingestion, trusted transformation, and presentation contracts. Physical storage can follow workload and recovery needs.

I choose a layer when it adds a clear control: restartable loads, historical truth, or fast and stable reporting. If a mart duplicates a warehouse table without simplifying access or performance, remove the unnecessary copy. Architecture should earn its rent.

Plan Refresh and Reader Isolation

Staging loads can be messy and interruptible. Warehouse updates need transaction boundaries and history rules. Mart refreshes should avoid showing half a new day to readers. Load into a separate table or partition and switch or swap during a controlled step where supported. Record the data-as-of time on reports.

I test a reader during refresh, not just after it. A dashboard that briefly doubles revenue is memorable for the wrong reason. The refresh design should make old complete data preferable to new incomplete data.

Trace a Metric Backward

Pick one dashboard number and trace it from mart row to warehouse fact to source staging batch. Record the transformation, validation, and time at each step. That exercise exposes missing lineage and inconsistent grains quickly. It also gives support staff a way to answer a user’s question without rebuilding the pipeline mentally.

Staging, warehouse and mart are useful when each layer has a clear job and owner. Keep the design as small as the team can operate. The goal is a trusted answer with a path back to its source, not three schemas for decoration.

Give each layer a retention and rebuild rule. Staging can retain raw receipts for replay, the warehouse can retain trusted history, and a mart can hold a focused presentation for one audience. Without those rules, data is copied three times and nobody knows which copy to fix after an error.

I trace one metric backward from report to mart, warehouse fact, stage row, and source receipt. At each step, record the grain and any filter or transformation. That exercise reveals whether a total changed because source data changed or because a later layer grouped it differently. The three layers earn their place when they give you control and explanation. If a mart adds no useful contract, a warehouse view can serve the report directly.

Can you trace one reported total through the mart, warehouse, stage, and source without guessing at any filter?

Related reading on this blog: Why Staging Tables Earn Their Keep and Data Lineage Tracking in ETL Processes: Notes from the Field #124.

Before a layer earns its place: a checklist on the staging, warehouse and mart

A data layer is not another copy by habit, it is a boundary with a clear responsibility.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.

Business Intelligence, Data Warehousing, ETL, SQL Server
Previous Post
SQL SERVER – White Paper – Partitioned Table and Index Strategies Using SQL Server 2008
Next Post
SQL SERVER – Differences in Vulnerability between Oracle and SQL Server

Related Posts

3 Comments. Leave new

  • Hi Pinal,
    You have brought to light an important issue with Data warehouse designing. I guess it could also be viewed as the debate between Bill Inmon(Top Down) and Ralph kimball approaches (Bottom Up) approaches. Designing an enterprise wide datawarehouse and then flushing it down to departments(Data marts) is a very big challenge, it takes huge amount of resources (money and people) to achieve it. These kind of initiatives seem to be undertaken at big organisations where they have this kind of leverage.

    Thank you

    Reply
  • Very good article. Thanks for sharing. Kindly keep it up.

    Reply
  • Hennie de Nooijer
    December 18, 2009 1:30 pm

    Nice article. Currently i’ve a discussion with an Inmon guy. I’m a Kimball follower at this moment. I think it’s true that the inmon EDW cost more effort to set up than the kimball approach but there are arguments that changes in the Kimball architecture is difficult.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.