Project Structure

Structure our dbt projects

dbt Basics and Project Structure

    jaffle_shop
    ├── README.md
    ├── analyses
    ├── seeds
    │   └── employees.csv
    ├── dbt_project.yml
    ├── macros
    │   └── cents_to_dollars.sql
    ├── models
    │   ├── intermediate
    │   │   └── finance
    │   │       ├── _int_finance__models.yml
    │   │       └── int_payments_pivoted_to_orders.sql
    │   ├── marts
    │   │   ├── finance
    │   │   │   ├── _finance__models.yml
    │   │   │   ├── orders.sql
    │   │   │   └── payments.sql
    │   │   └── marketing
    │   │       ├── _marketing__models.yml
    │   │       └── customers.sql
    │   ├── staging
    │   │   ├── jaffle_shop
    │   │   │   ├── _jaffle_shop__docs.md
    │   │   │   ├── _jaffle_shop__models.yml
    │   │   │   ├── _jaffle_shop__sources.yml
    │   │   │   ├── base
    │   │   │   │   ├── base_jaffle_shop__customers.sql
    │   │   │   │   └── base_jaffle_shop__deleted_customers.sql
    │   │   │   ├── stg_jaffle_shop__customers.sql
    │   │   │   └── stg_jaffle_shop__orders.sql
    │   │   └── stripe
    │   │       ├── _stripe__models.yml
    │   │       ├── _stripe__sources.yml
    │   │       └── stg_stripe__payments.sql
    │   └── utilities
    │       └── all_dates.sql
    ├── packages.yml
    ├── snapshots
    └── tests
        └── assert_positive_value_for_total_amount.sql

Let's create data layer in dbt project

following this command:

mkdir -p models/staging/airlines/base models/intermediate models/marts

Config dbt_project.yml

models:
  airlines:
    +materialized: view
    staging:
      airlines:
        +materialized: view
        +schema: staging
    intermediate:
      +materialized: table
      +schema: intermediate
    marts:
      +materialized: view
      +schema: reporting