A dbt model is a SQL (or Python) file that defines one relation in the warehouse: usually a view or table that other models and BI tools can query.
Tiny example
models/staging/stg_orders.sql:
select
id as order_id,
customer_id,
cast(order_date as date) as order_date,
amount_cents / 100.0 as amount
from {{ source('raw', 'orders') }}When you run dbt run --select stg_orders, dbt compiles the Jinja and executes something like:
create or replace view analytics.stg_orders as ( select ... from raw.orders );
Mental model
One model file ≈ one named dataset in the warehouse
|
+-- depends on sources and/or other models
+-- materializes as view / table / incremental / ephemeralCommon project layers
staging/: light cleanup, renaming, typing (1:1 with sources)intermediate/: reusable business logicmarts/: facts and dimensions for consumers
Interview tip: The model is the *definition* of the dataset. Materialization (view vs table vs incremental) is a separate config choice about how that definition is stored and refreshed.