Skip to content
BENIBIX Learn

dbt Model

Data⚙️ ProcessingData Transformation

Also known as Model (dbt), dbt SQL Model

One SQL file in dbt. It builds one table or view.

Think of it like

It is like one card in a recipe box. It makes one dish, and it can use dishes made by other cards.

Example

One model file adds up orders by day. dbt turns it into a table in the warehouse with the same name.

Why it matters

Models are the building blocks of a dbt project. Small models are easy to test and reuse.

Definition

A dbt model is one SQL file that holds one SELECT statement. When dbt runs, it wraps the SELECT. It builds a table or a view with the file's name. A model reads other models with ref() and raw tables with source(). A setting says how it is built: as a table, a view, or by adding new rows.

Example code

sql
-- models/daily_sales.sql
SELECT order_date, SUM(total) AS sales
FROM {{ ref('stg_orders') }}
GROUP BY order_date
This model builds the sales table for each day. It reads from a second model.

Common mistake

Making every model a table. Light steps can be views, which cost no storage and are always fresh.

Key takeaways

  1. 1
    One file, one table. The name is the file name.
  2. 2
    Only a SELECT. dbt writes the rest.
  3. 3
    ref() and source(). How models find their inputs.