0
0
dbtdata~20 mins

One model per source table rule in dbt - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
One Model Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why follow the one model per source table rule in dbt?

In dbt, why is it recommended to create exactly one model for each source table?

AIt automatically creates indexes on all source tables.
BIt reduces the number of SQL queries dbt runs, improving performance.
CIt allows multiple models to write to the same table simultaneously.
DIt simplifies debugging and testing by isolating transformations per source table.
Attempts:
2 left
💡 Hint

Think about how isolating transformations helps when you want to find errors or test data.

Predict Output
intermediate
2:00remaining
Output of dbt model with one source table

Given this dbt model SQL code that selects all columns from a source table, what will be the output schema?

dbt
select * from {{ source('sales_db', 'orders') }}
AAn empty table because no filters are applied.
BAn error because source() function is not valid in dbt models.
CA table with all columns from the 'orders' source table.
DA table with only the primary key column from 'orders'.
Attempts:
2 left
💡 Hint

The source() function references the source table directly.

data_output
advanced
2:00remaining
Resulting row count after one model per source table transformation

Assume the source table 'customers' has 1000 rows. A dbt model applies a filter to select only customers from 'USA'. If 300 rows match, how many rows will the model output have?

A300 rows, because the filter selects only USA customers.
B1000 rows, because the model does not change row count.
C0 rows, because filters are ignored in dbt models.
D1300 rows, combining all customers and filtered ones.
Attempts:
2 left
💡 Hint

Filters in SQL reduce the number of rows returned.

🔧 Debug
advanced
2:00remaining
Identify the error in violating one model per source table rule

Which problem arises if you create multiple dbt models that transform the same source table independently?

AData duplication and inconsistent transformations across models.
Bdbt automatically merges models, so no problem occurs.
CThe source table gets deleted after the first model runs.
Ddbt throws a syntax error during compilation.
Attempts:
2 left
💡 Hint

Think about what happens if you have different versions of the same data.

🚀 Application
expert
3:00remaining
Best practice application of one model per source table rule

You have three source tables: 'orders', 'customers', and 'products'. You want to build a sales report model that combines data from all three. According to the one model per source table rule, how should you organize your dbt models?

ACreate one big model that directly queries all three source tables and produces the report.
BCreate three separate models, one for each source table, then create a fourth model that joins these three models for the report.
CCreate one model per source table and duplicate the join logic in each model.
DCreate a single model that copies all source tables into one table before reporting.
Attempts:
2 left
💡 Hint

Think about modularity and reusability in dbt models.