# dbt Fundamentals

> Build transformation pipelines as SQL models with dbt: sources, ref, materializations, project structure, documentation and the DAG. Free notes, key concepts,...

Canonical: https://www.internhack.in/roadmaps/tracks/data-engineer/dbt-fundamentals
Last updated: 2026-11-28

Build transformation pipelines as SQL models with dbt: sources, ref, materializations, project structure, documentation and the DAG.

Intermediate · about 10 hours · difficulty 3/5

Learn first: [ETL vs ELT and Load Patterns](https://www.internhack.in/roadmaps/tracks/data-engineer/etl-vs-elt), [Dimensional Modeling: Star and Snowflake Schemas](https://www.internhack.in/roadmaps/tracks/data-engineer/dimensional-modeling), [Git and Collaborative Workflows](https://www.internhack.in/roadmaps/tracks/data-engineer/git)

dbt (data build tool) turns SQL SELECT statements into a managed, tested, documented transformation pipeline inside your warehouse. It is now a default skill for data and analytics engineers, and dbt Core is free and open source.

### The core idea

Each **model** is a `.sql` file containing a SELECT. dbt wraps it in the right DDL and builds it as a view or table. Models reference each other with `{{ ref('stg_orders') }}`, which lets dbt build a **DAG** and run models in dependency order.

### Key building blocks

- **Sources**: declare raw tables in YAML and reference them with `{{ source('razorpay', 'payments') }}`. You can check source **freshness**.
- **Materializations**: `view`, `table`, `incremental`, `ephemeral`. Choose per model.
- **Project structure**: `staging` (one model per source table, renames and casts), `intermediate`, `marts` (facts and dimensions).
- **YAML properties**: descriptions, column docs and tests live next to models.
- **Seeds**: small CSVs (like a mapping of state codes) version-controlled with the project.

### Commands

`dbt run`, `dbt test`, `dbt build` (run and test in order), `dbt docs generate` and `dbt docs serve` for a browsable catalog with lineage graphs. Select subsets with `--select stg_orders+`.

### Environments

Use separate **targets** (dev schema per developer, prod schema) in `profiles.yml`. CI runs dbt on pull requests before merging.

### Pitfalls

- Hard-coding table names instead of using ref and source, breaking lineage and environments.
- Putting all logic in one 500-line model.

You are ready to move on when you can build a dbt project with sources, staging and mart models, generate docs with a lineage graph, and run it against DuckDB, Postgres or a warehouse.

## Key concepts

- **Models and ref**
- **Sources and freshness**
- **Materializations**
- **Staging, intermediate, marts**
- **Seeds**
- **dbt build and node selection**
- **dbt docs and lineage**
- **Profiles and targets**

## Mini project

Create a dbt Core project using dbt-duckdb or BigQuery over a sample e-commerce dataset. Build staging models for each source, a fct_orders and dim_customers mart, add descriptions, and publish the generated docs site via GitHub Pages.

## Check yourself

What does ref() give you that writing the full table name does not?

## Free resources

- [dbt documentation](https://docs.getdbt.com/docs/introduction) (dbt Labs)
- [How we structure our dbt projects](https://docs.getdbt.com/best-practices/how-we-structure/1-guide-overview) (dbt Labs)
- [Data Engineering Zoomcamp (analytics engineering module)](https://github.com/DataTalksClub/data-engineering-zoomcamp) (DataTalksClub)

Previous: [Managed Ingestion and Change Data Capture](https://www.internhack.in/roadmaps/tracks/data-engineer/ingestion-cdc) · Next: [Advanced dbt: Incremental Models, Snapshots and Macros](https://www.internhack.in/roadmaps/tracks/data-engineer/dbt-advanced)

## More in ELT and Transformation with dbt

- [ETL vs ELT and Load Patterns](https://www.internhack.in/roadmaps/tracks/data-engineer/etl-vs-elt)
- [Managed Ingestion and Change Data Capture](https://www.internhack.in/roadmaps/tracks/data-engineer/ingestion-cdc)
- [dbt Fundamentals](https://www.internhack.in/roadmaps/tracks/data-engineer/dbt-fundamentals)
- [Advanced dbt: Incremental Models, Snapshots and Macros](https://www.internhack.in/roadmaps/tracks/data-engineer/dbt-advanced)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Data Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/data-engineer)
