0
0
dbtdata~5 mins

Model naming conventions in dbt

Choose your learning style9 modes available
Introduction

Good model names help you and others understand what the data is about quickly. They make your work clear and easy to follow.

When creating new data models in dbt to keep your project organized.
When sharing your dbt project with teammates so everyone understands the data.
When debugging or updating models to find them easily by name.
When documenting your data pipeline for future reference.
When automating deployments and you need consistent naming.
Syntax
dbt
model_name: descriptive_name_with_underscores

Example: sales_summary_by_month

Use lowercase letters and underscores to separate words.

Keep names short but descriptive enough to understand the model's purpose.

Examples
This name clearly shows the model contains customer orders data.
dbt
customer_orders

-- A model showing all orders by customers
Use underscores to separate words for readability.
dbt
daily_revenue_report

-- A model summarizing revenue each day
Descriptive names help you know what data the model holds.
dbt
product_inventory_status

-- A model tracking product stock levels
Sample Program

This model is named sales_summary_by_month to clearly show it summarizes sales data by month.

dbt
-- dbt model file: models/sales_summary_by_month.sql

select
  date_trunc('month', order_date) as month,
  sum(amount) as total_sales
from {{ ref('raw_orders') }}
group by 1
order by 1;
OutputSuccess
Important Notes

Avoid using spaces or special characters in model names.

Consistent naming helps when writing documentation or tests.

Use prefixes or suffixes if needed to group similar models, like stg_ for staging or int_ for intermediate models.

Summary

Use clear, lowercase names with underscores.

Names should describe what the model does or contains.

Consistent naming makes your dbt project easier to understand and maintain.