Models and Sources in dbt

One of the key advantages of DBT is the modularisation aspect were it refers to the practice of breaking down complex data into smaller, more manageable pieces. The main way to do this is through building models and sources as seen in the lineage graph below.

Models

Models are SQL select tables in your DBT project. Each contain logic that will take the raw data and build it into the finished project.

Models are broken down into staging and marts models as seen in the models folder below.

Staging Models

Staging models are the first layer of transformation in your DBT pipeline. They contain

  • Basic cleaning and preprocessing
  • Basic transformations
  • Low-level operations

They don't usually contain business logic and instead refine raw data to make it easier to work with in downstream (upcoming) models.

Building a model in DBT is very similar to SQL syntax (see below). Here we have labelled the file .sql which indicates the file contains SQL script and have used the same syntax as we would in any DBT database.

Marts Models

Marts represents a more refined, business layer of your DBT project and for the use of the analytics team to provide valuable insights. They usually contain:

  • Business logic: aggregations and calculations
  • Final datasets

Model Summary

Marts take data from the staging orders model (which is clean and processed) and then aggregates this data into the final report.

Sources

Sources represent the raw data that originates from databases before any transformation occurs. The sources functionality allows you to define these sources in a structured way, making it easy to reference them in your dbt models, track changes and ensure data integrity.

Sources are defined in a .yml file located in the models directory. Yml files define the schema and table name and allow for tests and documentation to be applied to the sources.

To then refer to a source in a model, you can use the same SQL syntax and state from {{ source('name', 'schema') }}

Author:
Priya Kondola
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2025 The Information Lab