dbt Fundamentals
Back to dbt Foundations: What and Why

Models — The SQL File as the Atom

One file, one SELECT, one materialized table or view. The dbt model is the unit of work. FIND_VIDEO: search 'dbt model SQL file basics' — recommended channel: dbt Labs. Aim for 9 min or under.

14 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.
Loading progress...

Key moments

  1. Defining DBT Models — Introduces dbt models as SQL or Python files housing atomic business transformations.
  2. Materialization Concepts — Explains how dbt maps SQL SELECT files to physical tables and views.
  3. Running Single Models — Demonstrates executing an individual model using the dbt run command.
  4. Referencing Models with ref() — Covers using the ref macro to link models and establish execution dependencies.
  5. Configuring Materializations — Reviews the config macro syntax for controlling materialization types and attributes.
  6. Creating Permanent Tables — Walks through configuring and building permanent tables with full fail-safe storage.
  7. Creating Transient Tables — Shows how to configure transient tables to reduce warehouse storage overhead.
  8. Creating Normal Views — Demonstrates materializing a model as a standard SQL view.
  9. Creating Secure Views — Explains configuring secure views to restrict visibility of underlying SQL definitions.
  10. Resolving Fully Qualified Names — Validates the compilation of ref macros into complete database.schema.object identifiers.
PDF notes

Frequently asked questions

What happens under the hood when I use the ref() function?

dbt resolves the model dependency graph to ensure proper build order, then replaces the ref call with the target database's fully qualified name (database.schema.table).

What is the primary difference between a permanent table and a transient table in dbt?

Permanent tables retain fail-safe data recovery capabilities, while transient tables omit fail-safe to lower warehouse storage costs.

Why would I materialize a model as a secure view instead of a standard view?

Secure views prevent unauthorized users from viewing the underlying SQL logic or query plan optimizations that might expose sensitive data.

How was this lesson?

Your feedback helps us refine explanations and catch bugs.