Good model names help you and others understand what the data is about quickly. They make your work clear and easy to follow.
Model naming conventions in dbt
Start learning this pattern below
Jump into concepts and practice - no test required
or
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
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
dbt
customer_orders -- A model showing all orders by customers
dbt
daily_revenue_report -- A model summarizing revenue each day
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;
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.
Practice
1. Which of the following is the best practice for naming a dbt model?
easy
Solution
Step 1: Understand dbt naming conventions
dbt recommends using clear, lowercase names with underscores to separate words for readability and consistency.Step 2: Evaluate each option
Use clear, lowercase names with underscores to separate words follows the recommended style. Options A, B, and D do not follow best practices.Final Answer:
Use clear, lowercase names with underscores to separate words -> Option AQuick Check:
Clear lowercase with underscores = C [OK]
Hint: Choose lowercase with underscores for clarity [OK]
Common Mistakes:
- Using uppercase letters in model names
- Including spaces or special characters
- Using inconsistent naming styles
2. Which of these is a valid dbt model name?
easy
Solution
Step 1: Check naming rules for dbt models
Model names should be lowercase and use underscores to separate words, avoiding special characters and uppercase letters.Step 2: Analyze each option
customer_orders uses lowercase letters and underscores only, making it valid. Options B, C, and D contain uppercase letters or special characters.Final Answer:
customer_orders -> Option AQuick Check:
Lowercase with underscores = A [OK]
Hint: Pick lowercase with underscores, no special chars [OK]
Common Mistakes:
- Using uppercase letters in model names
- Including hyphens or special characters
- Starting names with numbers
3. Given the following dbt model names, which one best describes a model that summarizes monthly sales data?
monthly_sales_summarysalesMonthlySummarymonthly-sales-summaryMonthlySalesSummarymedium
Solution
Step 1: Identify the best naming style for dbt models
dbt prefers lowercase names with underscores to separate words for clarity and consistency.Step 2: Compare each model name
monthly_sales_summary uses lowercase with underscores and clearly describes the model. Options A and B use camel case or uppercase letters, and C uses hyphens, which are not recommended.Final Answer:
monthly_sales_summary -> Option DQuick Check:
Lowercase with underscores = D [OK]
Hint: Look for lowercase with underscores describing content [OK]
Common Mistakes:
- Using camelCase or PascalCase
- Using hyphens instead of underscores
- Ignoring clarity in names
4. You have a dbt model named
CustomerOrders. What is the issue with this name and how can you fix it?medium
Solution
Step 1: Identify naming convention violation
The model name uses uppercase letters, which is against dbt's lowercase naming convention.Step 2: Apply correct naming style
Rename the model to lowercase letters with underscores:customer_orders.Final Answer:
It uses uppercase letters; rename tocustomer_orders-> Option BQuick Check:
Uppercase letters not allowed = A [OK]
Hint: Rename uppercase to lowercase with underscores [OK]
Common Mistakes:
- Ignoring uppercase letters in names
- Removing underscores instead of fixing case
- Adding unnecessary special characters
5. You want to create a dbt model that calculates the total revenue per product category for the last year. Which model name follows best practices and clearly describes the model's purpose?
hard
Solution
Step 1: Understand naming best practices
dbt model names should be lowercase, use underscores, and clearly describe the model's content.Step 2: Evaluate each option
total_revenue_per_category_last_year uses lowercase letters and underscores, and clearly describes the model. Options A and C use uppercase or camel case, and D uses hyphens.Final Answer:
total_revenue_per_category_last_year -> Option CQuick Check:
Lowercase with underscores and clear description = B [OK]
Hint: Use lowercase with underscores and descriptive words [OK]
Common Mistakes:
- Using camelCase or PascalCase
- Using hyphens instead of underscores
- Using uppercase letters
