📘Introduction

In this hands-on dbt tutorial, we’ll walk step by step through how to apply the Medallion Architecture to a real dataset using dbt.
We’ll explore a sample dataset, visualize the dataflow, and move through all layers of the architecture:

1️⃣ 🛬 Landing Layer – Raw data ingestion
2️⃣ 🥉 Bronze Layer – Standardizing and cleaning raw data
3️⃣ 🥈 Silver Layer – Transforming and ensuring data quality
4️⃣ 🥇 Gold Layer – Business-ready data

✅ Prerequisites

☑️ A dbt project set up
☑️ Set up Medallion Architecture
☑️ Source data loaded into your data warehouse

🏅Set up Medallion Architecture in dbt project

We’ve already set up our dbt project according to the Medallion Architecture.
If you haven't done that yet or want a detailed walkthrough, check out this guide:

Set up Medallion Architecture with dbt: From Raw Data to Gold Standard
Introduction In the age of data-driven decision making, having a powerful data architecture is crucial. The Medallion Architecture is a proven data architecture pattern that helps in organizing data across different layers of refinement. When combined with dbt (data build tool), it becomes a powerful and scalable way to manage

Your models folder in dbt reflects the Medallion layered structure.

💾 Sample Dataset and Requirement

For this tutorial, we’ll use a fictive university dataset. We assume the data is coming from a fictive system called SIS – Student Information System, provided as CSV exports.

🎓 course.csv

id,code,credits,level,semester_number
c1,DBA,20,,1
c2,PRG,20,,2
c3,STA,20,Basic,3
c4,DEN,10,Advanced,4
c5,DCG,10,,4
c6,MLG,10,,4
c7,DMN,10,Advanced,5
c8,ETL,10,Advanced,5
c9,DLG,10,Advanced,5
c10,DVN,10,Advanced,6
c11,API,10,,6
c12,CVN,10,Advanced,6

🔗 course_mapping.csv

Code,Name
DBA,Databases
DBA,Databases
PRG,Programing
PRG,Programing
STA,Statistics
STA,Statistics
DEN,Data Exploration
DCG,Data Cleansing
MLG,Machine Learning
DMN,Data Modeling
DMN,Data Modeling
DMN,Data Modeling
ETL,Extract Transform Load
DLG,Deep Learning
DLG,Deep Learning
DVN,Data Visualization
DVN,Data Visualization
DVN,Data Visualization
API,Application Programming Interface
CVN,Computer Vision
CVN,Computer Vision

🎯 Goal: Clean, standardize, transform, and join the data to produce a business ready table dim_course.

🔀 Dataflow Diagram

This is how the dataflow should look through the layers: the data is cleaned in Bronze, transformed in Silver, and combined in Gold.

1️⃣🛬 What happens in Landing?

The Landing Zone is where raw data is first ingested — in our example, via CSV using Python.

📁 dbt project

This is how the landing zone looks like in our dbt project. There is only a .yml file:

The .yml  file contains the information about the source tables in the warehouse.:

version: 2

sources:
 - name: sis
    database: dev_dlnerds_university 
    schema: landing
    tables:
      - name: course
      - name: course_mapping

🏠 Warehouse

The tables are stored in the warehouse under the landing schema.

This is how the data looks like:

course

course_mapping

2️⃣🥉What happens in the Bronze Layer?

The Bronze Layer is where data is cleaned and brought into a standardized format.
In our example, we:
- Rename all columns to lowercase
- Add a source_name column to track the origin of the data

📁 dbt project

This is how the Bronze Layer looks like in our db project. We created two models cleaned_course and cleaned_course_mapping:

🚰 Pipeline

Let's have a look at the code of the two models.

cleaned_course

SELECT
    id,
    code,
    credits,
    level,
    semester_number,
    'sis' AS source_name
FROM {{ source("sis", "course") }}

cleaned_course_mapping

SELECT
    Code AS code,
    Name AS name,
    'sis' AS source_name
FROM {{ source("sis", "course_mapping") }}

Use dbt run to execute the models and load the data into your warehouse.

🏠 Warehouse

The tables are stored in the warehouse under the bronze schema.

This is how the data looks like:

cleaned_course

cleaned_course_mapping

3️⃣🥈What happens in the Silver Layer?

You can view this post with the tier: Academy Membership

Join academy now to read the post and get access to the full library of premium posts for academy members only.

Join Academy Already have an account? Sign In