0
0
dbtdata~15 mins

Group-based ownership in dbt - Mini Project: Build & Apply

Choose your learning style9 modes available
Group-based ownership
📖 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
Need a 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
Need a 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
Need a 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
Need a hint?

Use print(owned_tables) to show the tables owned by the marketing group.