3. Clean layers: bronze, silver and gold
3.1 Bronze, silver, gold: three levels of clean
Highlights & notes
Select lesson text to highlight it, or tap Add note.
Bookmarks
Bookmark a lesson to see it here.
Think of a kitchen. Vegetables arrive with mud on them: that is bronze. You wash and cut them: silver. You cook the dish that people eat: gold. Data pipelines use the same three steps. The pattern is called the medallion architecture.
- Bronze: raw data, exactly as it arrived. Nothing is deleted. Only engineers look here.
- Silver: cleaned data. Right types, no duplicates, bad rows removed.
- Gold: ready-made answers for the business, such as daily sales per city. Dashboards read gold.
In BigQuery each layer is usually its own dataset: bronze, silver and gold. The name then tells you how far to trust a table. silver.orders is clean. bronze.orders_raw is not.
Why keep three copies?
- A cleaning rule was wrong → rebuild silver from bronze. Nothing is lost.
- A dashboard number looks odd → trace gold back to silver, then to bronze.
- Analysts never touch messy data, so they make fewer mistakes.
Data moves one way only: bronze → silver → gold. Never load files straight into silver, and never let a dashboard read bronze.
Make a messy bronze table
Run this once. It creates the three datasets and a small raw table with real-life problems in it.
CREATE SCHEMA IF NOT EXISTS bronze;
CREATE SCHEMA IF NOT EXISTS silver;
CREATE SCHEMA IF NOT EXISTS gold;
CREATE OR REPLACE TABLE bronze.orders_raw AS
SELECT * FROM UNNEST([
STRUCT('101' AS order_id, ' Noida ' AS city, '55000' AS amount),
('101', ' Noida ', '55000'),
('102', 'DELHI', '700'),
('108', 'Pune', CAST(NULL AS STRING))
]);How it fits together
- Bronze: raw
- Silver: clean
- Gold: business answers
One table travels through the layers
Bronze has a repeated row, messy city names and a missing amount.
SQL
CREATE OR REPLACE TABLE silver.orders ASSELECT DISTINCT CAST(order_id AS INT64) AS order_id, LOWER(TRIM(city)) AS city, CAST(amount AS INT64) AS amountFROM bronze.orders_rawWHERE amount IS NOT NULL;CREATE OR REPLACE TABLE gold.sales_by_city ASSELECT city, SUM(amount) AS total_salesFROM silver.ordersGROUP BY city;
Rows at this step
city | total_sales ------+------------ noida | 55000 delhi | 700
Try it yourself
1. Run the Make a messy bronze table script above.
2. Run the two statements from the walkthrough.
3. Open gold.sales_by_city. You should see two rows: noida and delhi.
Question 1 · Easy
Which layer holds data exactly as it arrived?
Question 2 · Medium
Where should a sales dashboard read from?
Question 3 · Hard
The rule that cleans city names was wrong for a whole month. Why is the fix easy in a medallion design?
Key takeaways
Medallion architecture has three layers. Bronze keeps raw data, silver holds clean data and gold holds business answers. Data flows one way: bronze → silver → gold.
Save your progress
Start free and your progress, code and notes stay saved. Free for 1 month, no card needed.
Start free Log in