Module 5 of 16

Intermediate Models

Build reusable transformation steps without exposing half-finished business tables.

95 minutes1 exercisesFree

Start here

Learning objectives

  • Know when to create an intermediate model
  • Separate reusable logic from final reporting shape
  • Reduce duplication across marts
Intermediate Models Follow the arrows. Each box is one idea you will practice in this module. Stage step 1 Join step 2 Derive step 3 Reuse step 4 Mart step 5 Production analytics engineering turns raw records into governed, trusted business meaning.

The Mental Model

Intermediate models hold reusable transformation logic that is too complex for staging but not final enough for business users.

Intermediate models are the prep bowls in a kitchen. They are useful while cooking, but you do not serve them as the final dish.

Tiny Example

We will use a small ecommerce dataset throughout the course. Think of these as the only tables in your first warehouse:

TableGrainExample columns
raw_ordersone row per order eventorder_id, customer_id, amount, status, created_at
raw_order_itemsone row per item inside an orderorder_id, product_id, quantity, item_price
raw_customersone row per customercustomer_id, email, country, created_at

Interactive Check

Question: Two marts need the same order refund calculation. Should both copy the SQL?

Reveal the answer

No. Put the shared refund logic in an intermediate model, then let both marts ref it.

Inline Practice Lab

This lab is intentionally small. You can solve it by reading the table, writing the SQL/YAML mentally, or pasting the snippet into any SQL scratchpad later.

-- Example starter table
select
  order_id,
  customer_id,
  amount,
  status,
  created_at
from raw_orders;

The goal is not tooling setup. The goal is learning the production habit: state the grain, clean one thing, test one assumption, and explain the downstream impact.

Self-Check Quiz

  1. What is the grain of the table you are building?
  2. Which downstream metric or dashboard would be wrong if this model broke?
  3. What test would catch the most likely beginner mistake here?

Real world

Where this shows up

  • Reliable executive dashboards that do not disagree across teams
  • AI analytics agents that query governed metrics instead of guessing SQL
  • Auditable metric changes where owners can see downstream impact before merge

Production notes

Keep these close

  • Intermediate models are useful, but too many create a maze. Each one should remove real duplication or clarify complex logic.

Common mistakes

What usually breaks

  • Creating intermediate models for every tiny SELECT
  • Letting BI tools query intermediate models directly
  • Hiding important business definitions without documentation

Think like an engineer

Questions to answer before shipping

  • Can you explain the grain of this model in one sentence?
  • What breaks downstream if this field becomes null tomorrow?
  • Where should this logic live so it is reused instead of copied?

Key terms

Vocabulary used in this module

Intermediate model

A model that captures reusable logic between staging and final marts.

DRY

Do not repeat yourself; centralize shared logic once.

Exercises

Practice inside the lesson

30-45 minutesBeginner to Intermediate

Extract Shared Logic

Move repeated refund and order status logic into one intermediate model.

  1. Find duplicated CASE expressions
  2. Create int_order_status_enriched
  3. Point downstream marts to the intermediate model
  4. Explain what duplication disappeared

Recap

Key takeaways

  • Intermediate models reduce repeated business logic
  • They should usually not be consumed directly by BI users
  • Good naming makes hidden transformation steps easier to debug

Related resources

Keep learning across CodersSecret