Skip to content

Shaping a model's dependency graph so it stays readable

A clean dbt DAG is built by chaining models with the ref() function so dbt can infer dependencies, determine run order, and parallelize execution safely. Well-designed lineage flows from sources through staging, intermediate, and mart layers in one direction, avoiding circular or crossed dependencies. Building logical flow is as much about naming, folder structure, and layering conventions as it is about the ref() and source() functions themselves.

1 · Learn the must-know

  • Always use ref() (and source() for raw tables) instead of hardcoded table names so dbt can build an accurate dependency graph and DAG visualization.
  • Follow a layered architecture (staging → intermediate → marts) so each model has a single, clear purpose and downstream models never skip layers unnecessarily.
  • Staging models should reference only source() calls, never other staging or downstream models, to keep the base of the DAG clean and consistent.
  • Avoid circular references; dbt will throw a compilation error if models depend on each other directly or indirectly in a loop.
  • Use intermediate models to encapsulate complex joins or transformations, keeping mart models simpler and easier to trace visually in the DAG.
  • A DAG that fans out too widely from one model or has excessive layers can indicate poor modularity; aim for logical, digestible dependency chains rather than monolithic models.

2 · Check your understanding

Check this objectiveFree · always available

Which statement about organizing a dbt project into staging, intermediate, and marts layers is correct?

Your objective map0 tried · 0 answered correctly · 31 untouched

What you have tried across dbt Analytics Engineering's objectives, not a readiness score.

Developing and optimizing dbt models45.16% of the exam*0 of 14 tried
Managing dbt models governance9.68% of the exam*0 of 3 tried
Debugging data modeling errors16.13% of the exam*0 of 5 tried
Troubleshooting and optimizing dbt pipelines6.45% of the exam*0 of 2 tried
Implementing dbt tests9.68% of the exam*0 of 3 tried
Implementing and maintaining external dependencies6.45% of the exam*0 of 2 tried
Leveraging the dbt state6.45% of the exam*0 of 2 tried

* Our estimate. dbt Labs publishes no section weights.

3 · Keep going