dbt (data build tool) fundamentals are transforming how data teams build, test, and deploy analytics code. dbt abstracts away the complexity of writing SQL and provides a framework for building modular, testable, maintainable data pipelines. Understanding dbt architecture is critical for modern data engineers.
Understanding dbt Project Fundamentals
dbt is a command-line tool that transforms raw data into clean, curated, analytics-ready data. Think of it as “Git for data”: version-controlled SQL, modular logic, automated testing, and CI/CD deployment. dbt compiles Jinja2-templated SQL into actual SQL queries your database executes.
A dbt project is a directory containing: models/ (SQL files defining transformations), tests/ (data quality tests), macros/ (reusable Jinja2 code), seeds/ (CSV files loaded as tables), and configuration files (dbt_project.yml, profiles.yml).
dbt Project Directory Structure
├── dbt_project.yml
├── profiles.yml
├── README.md
├── models/
│ ├── staging/
│ ├── marts/
│ └── intermediate/
├── tests/
├── macros/
├── seeds/
└── analysis/
dbt_project.yml: The Project Manifest
dbt_project.yml is the heart of your dbt project. It defines project name, version, database configuration, model paths, and materialization defaults. The config section specifies how models are built (tables, views, incremental). Seeds define CSV loading. Requires section manages dependencies between models.
profiles.yml: Database Connection Configuration
profiles.yml stores database credentials (host, port, user, password, schema). It’s .gitignored to prevent credential leaks. Environment variables substitute sensitive data. Different profiles support dev/staging/prod environments.
Dependencies and Package Management
dbt packages are reusable macros and models published on dbtHub. The packages.yml file declares external dependencies. Use dbt deps to install packages into dbt_packages/ directory. Packages enable code reuse across projects.
Model Dependencies: ref() and source()
dbt builds a DAG (Directed Acyclic Graph) of model dependencies. ref() references upstream dbt models (compile-time check). source() references raw data (version-tracked). This DAG ensures proper execution order and enables selective runs.
5 Complete Interview Questions with Solutions
Question 1: dbt Project Initialization and Configuration
You need to initialize a dbt project connecting to Snowflake with staging/marts folder structure. Walk through the setup, including dbt_project.yml and profiles.yml configuration.
$ cd my_analytics_project
# profiles.yml setup (Snowflake)
my_analytics:
outputs:
dev:
type: snowflake
account: xy12345.us-east-1
user: dbt_user
password: “{{ env_var(‘SF_PASSWORD’) }}”
role: DEVELOPER
database: ANALYTICS_DEV
schema: TRANSFORMED
threads: 4
target: dev
Explanation: dbt init scaffolds project structure. profiles.yml stores credentials securely. dbt_project.yml specifies materialization, schema, and paths. Environment variables prevent secrets in version control.
Databricks – Senior Data Engineer
Question 2: Understanding ref() vs source() Dependencies
Explain the difference between ref() and source(). When building a dbt DAG, which creates compile-time dependencies and which creates lineage to raw data?
SELECT * FROM {{ source(‘raw_data’, ‘customers’) }}
— ref(): dbt models (internal dependencies)
SELECT * FROM {{ ref(‘stg_customers’) }}
— Key difference:
— ref() = compile-time dependency (hard dependency)
— source() = lineage tracking (soft reference)
Explanation: ref() creates hard dependencies within dbt. source() tracks external data lineage. This distinction is crucial for DAG execution and data lineage tracking.
Google – Senior Analytics Engineer
Question 3: Package Management with dbt deps
Your team needs reusable macros for data validation. How would you create a custom dbt package, publish it, and consume it in another project using packages.yml?
packages:
– package: company/dbt_validation_macros
version: 1.0.0
— Run: dbt deps
— Installs packages to dbt_packages/ directory
— Using in models
{% from “dbt_validation_macros.validate_column_values” import validate_column_values %}
Explanation: dbt packages enable code reuse across projects. Git packages work for private repos, dbtHub for public. dbt deps downloads packages to dbt_packages/.
LinkedIn – Senior Data Engineer
Question 4: Multi-Schema Project Configuration
Design a dbt_project.yml for a project with staging (raw cleanup), marts (business logic), and reports (dashboard tables). Each lives in different schemas with different materialization strategies.
analytics_project:
staging:
materialized: view
schema: staging
marts:
materialized: table
schema: marts
reports:
materialized: table
schema: reports
Explanation: Multi-schema config separates concerns: staging for cleaning, marts for analysis, reports for BI. Materialization reflects compute cost/recency.
Databricks – Senior Analytics Engineer
Question 5: dbt Project Dependencies and DAG Execution
Given models A (depends on B), B (depends on C), C (raw data), explain the execution order when running dbt run. How would you run only model A without running dependencies? When would you force rebuild all?
$ dbt run
# Executes: C → B → A (dependency order)
$ dbt run –select a
# Runs only A (assumes B exists)
$ dbt run –select a+
# Runs A and all upstream dependencies
$ dbt run –full-refresh
# Rebuilds all models from scratch
Explanation: dbt builds DAG from ref() dependencies. dbt run respects this ordering. Selection syntax controls what runs. –full-refresh forces rebuilds.
Google – Senior Analytics Engineer
15 Practice Questions (Test Yourself)
Question 6: Design a dbt project structure for a multi-tenant analytics platform where each tenant has isolated schemas. How would you configure dbt_project.yml to support tenant isolation, and what challenges arise with managing multiple tenant deployments?
Meta – Senior Data Engineer
Question 7: Explain how environment variables in profiles.yml enable safe credential management across dev, staging, and production environments. What would happen if database credentials were accidentally committed to Git, and how does dbt Cloud prevent this?
Google – Senior Analytics Engineer
Question 8: When should you use Git-based dbt packages versus dbtHub packages? What are the trade-offs in terms of versioning, discoverability, and maintenance overhead for enterprise projects?
LinkedIn – Senior Data Engineer
Question 9: Design source() definitions for a project that ingests from multiple raw data systems (Salesforce, Segment, internal APIs). How would you organize sources.yml files and validate data freshness across heterogeneous sources?
Uber – Senior Data Engineer
Question 10: Given a dbt project with 100+ models, how would you use tags and selection syntax to partition work across multiple dbt run commands for efficient parallel execution and faster CI/CD pipelines?
Meta – Senior Analytics Engineer
Question 11: Explain how dbt handles schema changes (adding/removing columns) across staging, marts, and reports layers. What breaks downstream when you remove a column that downstream models depend on, and how do you prevent it?
Google – Senior Data Engineer
Question 12: Design a versioning strategy for dbt packages that are consumed by multiple internal projects in your organization. How would you handle breaking changes without disrupting downstream teams and maintain backward compatibility?
LinkedIn – Senior Data Engineer
Question 13: Design a dbt project for a scenario where different business units need isolated transformations but share common staging models. What conflicts might arise from shared staging layers and how do you resolve them?
Google – Senior Analytics Engineer
Question 14: Explain the difference between dbt run, dbt build, and dbt test in the context of project execution. When would you use each command and why are they different in terms of test integration and model execution?
Airbnb – Senior Data Engineer
Question 15: How would you handle circular dependencies between dbt models? Can they actually happen in a well-designed project, and what architectural decisions prevent them at the design phase?
Google – Senior Data Engineer
Question 16: Design a dbt project configuration that supports zero-downtime migrations when adding new staging or marts layers to production. How would you handle the transition period where old and new models coexist?
Meta – Senior Data Engineer
Question 17: Explain how dbt seedfile functionality handles static lookup tables. When would you use seeds versus staging models versus external tables in terms of data volume and update frequency?
Google – Analytics Engineer
Question 18: How does dbt_project.yml version field impact compatibility when upgrading dbt versions? What specifically breaks when upgrading from version 1.0 to 1.5, and how do you handle migration?
Stripe – Senior Analytics Engineer
Question 19: Design a monorepo versus polyrepo strategy for dbt projects across your organization. What are the trade-offs in package management, testing, CI/CD complexity, and team autonomy when choosing each approach?
Google – Senior Data Engineer
Question 20: Explain how profiles.yml thread count affects dbt execution speed and database resource consumption. What is the optimal threading strategy for large projects with 500+ models and how do you tune it?
Stripe – Senior Data Engineer
Ready to Master dbt Project Management?
These 20 practice questions are just the tip of the iceberg. Get our comprehensive Data Analytics: Ace All The Interview Concepts course.