System Design · easy
What is the difference between a staging model and a mart in dbt, and why keep them separate?
Asked in Analytics Engineer interviews, in the System Design round.
Short answer
Staging is one-to-one with a source: rename, cast, and clean only, no business logic, no joins. Marts are the joined, business-shaped tables analysts query. Separating them means a source change is absorbed in one place, logic is reusable across marts, and each layer's contract can be tested on its own.
| Staging | Mart | |
|---|---|---|
| Grain | One model per source table | One model per business entity |
| Joins | None | Yes, that is the point |
| Business logic | None | Yes |
| Does | Rename, cast, clean, deduplicate | Combine, aggregate, apply definitions |
| Named | stg_charges, stg_users | dim_customer, fct_orders |
| Changes when | The source changes | The business definition changes |
| Why separate | A renamed source column is fixed in one place | Analysts read one clean layer, never raw |
How to answer it
Definition
Staging models clean one source table each. Marts join them into the entities the business asks about. The table above compares them; what follows is why the separation earns its keep.
The layers
sources raw, loaded by the pipeline, never edited
staging one model per source table
rename, cast, clean, deduplicate
no joins, no business logic
stg_stripe__charges, stg_app__users
intermediate (optional)
reusable joins that are not themselves a business entity
marts the entities people ask for, joined and tested
dim_customer, fct_orders
Why separate them
- A renamed source column is fixed in one staging model rather than in every mart that touched it. That single property is most of the argument.
- Staging gives a stable vocabulary, so downstream models never see the source's odd names and a source migration is invisible past that layer.
- Business logic lives in exactly one layer, so there is one place to look when a number is wrong.
- Testing splits usefully: staging tests source assumptions such as uniqueness and not-null; marts test business rules.
- Analysts read one clean layer and never touch raw.
The cost, honestly
More models and more files, and a staging model that only renames columns feels like ceremony on a small project. With three sources and one dashboard it probably is. The separation pays off with many sources and many consumers, which is where dbt projects usually end up.
Key points
- One staging model per source table, doing only mechanical cleaning.
- No joins and no business logic in staging. That constraint is what keeps it useful.
- Marts hold the joins, the business definitions and the tests that matter.
- The payoff is a single place to absorb a source change.
- Name them so the layer is obvious from the model name.
FAQ
- Should staging be views or tables? Views usually, since they are cheap and always fresh. Materialise if a source is expensive to scan.
- What goes in intermediate? A join reused by several marts that is not itself an entity anyone asks for.
- Is it overkill for a small project? Sometimes. Say so rather than applying it mechanically.
The 30-second answer
Staging is one model per source table doing only mechanical work: renaming, casting, light cleaning, no joins and no business logic. Marts are the entities the business actually asks about, where the joins and the definitions live and where the meaningful tests sit.
The reason to keep them separate is that a renamed source column then gets fixed in one staging model instead of in every mart that happened to touch it. It also gives downstream models a stable vocabulary, so a source migration stops at the staging layer and nothing else notices.
I would be honest that on a small project with three sources it can feel like ceremony. The payoff arrives with many sources and many consumers, which is where most dbt projects end up.
In the interview
- What they are checking: "one-to-one with the source, no business logic" for staging, and the change-isolation argument.
- Common mistake: a staging model that already joins customers to orders, so the next mart cannot reuse either half.