0
0
dbtdata~10 mins

Naming conventions at scale in dbt - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Naming conventions at scale
Define naming rules
Apply rules to models
Apply rules to sources
Apply rules to tests
Apply rules to snapshots
Check for consistency
Adjust rules if needed
Scale naming across project
Start by defining clear naming rules, then apply them step-by-step to all dbt components, check consistency, adjust if needed, and scale across the project.
Execution Sample
dbt
version: 2

models:
  - name: stg_customers
    description: 'Staging table for customers'
    tests:
      - unique:
          column_name: customer_id

sources:
  - name: raw_customers
This snippet shows applying naming conventions to models, sources, and tests in dbt YAML config.
Execution Table
StepComponentNaming Rule AppliedName ExampleResult/Output
1ModelPrefix with 'stg_' for stagingstg_customersName set to 'stg_customers'
2SourcePrefix with 'raw_' for raw dataraw_customersName set to 'raw_customers'
3TestUse descriptive test namesunique_customer_idTest named 'unique_customer_id'
4SnapshotPrefix with 'snap_' for snapshotssnap_ordersName set to 'snap_orders'
5Consistency CheckVerify all names follow rulesAll names checkedNo violations found
6Adjust RulesUpdate prefix if neededChange 'stg_' to 'stage_'Rules updated
7Scale NamingApply updated rules project-wideAll components renamedConsistent naming across project
8End--Naming conventions fully applied and consistent
💡 All components named consistently following defined conventions
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5After Step 6After Step 7Final
Model Namesundefinedstg_customersstg_customersstg_customersstg_customersstg_customersstage_customersstage_customersstage_customers
Source Namesundefinedundefinedraw_customersraw_customersraw_customersraw_customersraw_customersraw_customersraw_customers
Test Namesundefinedundefinedundefinedunique_customer_idunique_customer_idunique_customer_idunique_customer_idunique_customer_idunique_customer_id
Snapshot Namesundefinedundefinedundefinedundefinedsnap_orderssnap_orderssnap_orderssnap_orderssnap_orders
Naming RulesundefinedDefinedDefinedDefinedDefinedCheckedUpdatedAppliedFinalized
Key Moments - 3 Insights
Why do we use prefixes like 'stg_' or 'raw_' in names?
Prefixes help quickly identify the type of data or component, making it easier to understand and manage large projects. See execution_table steps 1 and 2 where prefixes are applied.
What happens if naming rules are not consistent across the project?
Inconsistent naming causes confusion and errors when referencing components. Step 5 in execution_table shows checking for consistency to avoid this.
Can naming conventions change after initial setup?
Yes, step 6 shows adjusting rules if needed, then scaling changes project-wide in step 7 to keep consistency.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at Step 3. What naming rule is applied to tests?
APrefix with 'stg_'
BPrefix with 'raw_'
CUse descriptive test names
DPrefix with 'snap_'
💡 Hint
Check the 'Naming Rule Applied' column at Step 3 in execution_table
At which step does the naming convention get updated?
AStep 4
BStep 6
CStep 5
DStep 7
💡 Hint
Look for 'Adjust Rules' in the 'Step' column of execution_table
According to variable_tracker, what is the final name for the model after all steps?
Astage_customers
Braw_customers
Cstg_customers
Dsnap_orders
💡 Hint
Check the 'Model Names' row in variable_tracker under 'Final' column
Concept Snapshot
Naming conventions at scale in dbt:
- Use clear prefixes like 'stg_' for staging, 'raw_' for sources
- Apply descriptive names for tests
- Check consistency regularly
- Adjust and scale naming rules project-wide
- Consistent names improve clarity and maintenance
Full Transcript
This visual execution shows how to apply naming conventions at scale in dbt projects. We start by defining naming rules such as prefixes for models, sources, tests, and snapshots. Then we apply these rules step-by-step to each component type. After applying, we check for consistency to ensure all names follow the rules. If needed, we adjust the naming rules and scale the changes across the entire project. The variable tracker shows how names change after each step. Key moments address why prefixes are important, the impact of inconsistent naming, and the possibility of updating conventions. The quiz tests understanding of naming rules applied at different steps and final naming outcomes. This approach helps keep large dbt projects organized and easy to understand.