📖 Scenario: You work in a company where different teams own different data tables. To keep track of who owns what, you want to create a simple ownership mapping using dbt.
🎯 Goal: Build a dbt model that creates a table showing each data table and the group that owns it.
📋 What You'll Learn
Create a dictionary mapping table names to owner groups
Create a variable for the group name to filter
Use a comprehension or filter to select tables owned by the group
Output the list of tables owned by the selected group
💡 Why This Matters
🌍 Real World
Companies often assign ownership of data tables to different teams to manage access and responsibility clearly.
💼 Career
Understanding group-based ownership helps data analysts and engineers organize data access and maintain data governance.
Progress0 / 4 steps
1
Create the ownership dictionary
Create a dictionary called table_owners with these exact entries: 'customers': 'sales', 'orders': 'sales', 'products': 'marketing', 'campaigns': 'marketing', 'employees': 'hr'.
dbt
Hint
Use curly braces {} to create a dictionary with keys as table names and values as group names.
2
Set the group to filter
Create a variable called selected_group and set it to the string 'marketing'.
dbt
Hint
Assign the string 'marketing' to the variable selected_group.
3
Filter tables owned by the selected group
Create a list called owned_tables that contains the keys from table_owners where the value equals selected_group. Use a list comprehension with for table, group in table_owners.items() and a condition.
dbt
Hint
Use a list comprehension to pick tables where the group matches selected_group.
4
Print the owned tables
Write a print statement to display the list owned_tables.
dbt
Hint
Use print(owned_tables) to show the tables owned by the marketing group.
Practice
(1/5)
1. What is the main benefit of using group-based ownership in dbt projects?
easy
A. It automatically fixes data errors in models.
B. It assigns responsibility to teams instead of just individuals.
C. It speeds up the dbt compilation process.
D. It removes the need for documentation.
Solution
Step 1: Understand group-based ownership purpose
Group-based ownership means assigning responsibility to a team, not just one person.
Step 2: Identify the benefit in collaboration
This improves teamwork and clarity on who manages data models.
Final Answer:
It assigns responsibility to teams instead of just individuals. -> Option B
Quick Check:
Group ownership = team responsibility [OK]
Hint: Group ownership means teams, not individuals [OK]
Common Mistakes:
Thinking it fixes data automatically
Confusing ownership with performance
Assuming it removes documentation needs
2. Which of the following is the correct way to assign a group owner in a dbt model configuration?
easy
A. owners: ['data_team']
B. owner = 'data_team'
C. groups: ['data_team']
D. team_owner: 'data_team'
Solution
Step 1: Recall dbt model ownership syntax
dbt uses the owners field as a list to assign group owners.
Step 2: Match correct syntax
The correct syntax is owners: ['group_name'], which matches owners: ['data_team'].
Final Answer:
owners: ['data_team'] -> Option A
Quick Check:
Use owners list for groups [OK]
Hint: Use owners: ['group_name'] to assign groups [OK]
Common Mistakes:
Using owner instead of owners
Using groups or team_owner fields which don't exist
Hint: Always use a list for owners, even if one group [OK]
Common Mistakes:
Using a string instead of a list
Misspelling owners field
Ignoring YAML syntax rules
5. You want to assign ownership of a dbt model to two groups: 'data_science' and 'qa_team'. Which configuration correctly sets this up and ensures both groups are notified on model changes?
hard
A. owners: ['data_science', 'qa_team']
B. owners: 'data_science, qa_team'
C. owner: ['data_science', 'qa_team']
D. groups: ['data_science', 'qa_team']
Solution
Step 1: Confirm correct field name and type
The field must be owners and a list of group names.
Step 2: Check options for correct syntax
owners: ['data_science', 'qa_team'] uses owners: ['data_science', 'qa_team'], which is correct.
Step 3: Understand notification implication
Assigning multiple owners ensures both groups are responsible and notified.
Final Answer:
owners: ['data_science', 'qa_team'] -> Option A
Quick Check:
Multiple owners list = multiple groups notified [OK]
Hint: Use owners list with all groups to notify them [OK]
Common Mistakes:
Using a string with commas instead of a list
Using owner instead of owners
Using groups field which is invalid
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.