What dbt does
dbt manages the T in ELT. You write SELECT statements; dbt compiles them into CREATE TABLE AS or CREATE VIEW AS statements and handles dependency ordering.
Project structure
models/
staging/ # 1:1 with source tables, light renaming
intermediate/ # joins and business logic
marts/ # final wide tables for analytics
Ref function
{{ ref('stg_orders') }} creates a dependency between models. dbt builds a DAG and executes in correct order. This replaces brittle hardcoded schema.table references.
Tests
- name: order_id
tests:
- unique
- not_null
Run dbt test after every build. Add custom SQL tests for business logic assertions.
Documentation
dbt docs generate && dbt docs serve produces a browsable data catalog with lineage graphs, column descriptions, and test results. Share the URL with analysts so they understand the data without asking engineers.