Module 6 of 16

Marts: Facts and Dimensions

Create the business-facing layer: facts, dimensions, and star schemas.

Updated

110 minutes1 exercisesFree

Start here

Learning objectives

  • Design simple fact and dimension tables
  • Understand star schema basics
  • Choose the right mart grain for reporting
Marts: Facts and Dimensions Follow the arrows. Each box is one idea you will practice in this module. Facts step 1 Dimensions step 2 Keys step 3 Schema step 4 Users step 5 Production analytics engineering turns raw records into governed, trusted business meaning.

The Mental Model

Marts are the tables business users and dashboards should trust. Facts store measurable events; dimensions store descriptive context.

If staging is clean ingredients and intermediate is prep work, marts are the served plates. This is the layer people actually consume.

Dataset reference: ecommerce tables and grain assumptions.

Choose the time meaning of a dimension

Customer C7 ordered on January 10 while living in France, then moved to Germany on February 1. A current-state customer dimension classifies the old order as Germany. An order-time dimension classifies it as France. Both can be valid, but they answer different questions.

RelationGrainKey rule
fct_ordersOne row per completed orderUnique, non-null order_id
dim_customers_currentOne row per customerUnique customer_id
dim_customers_historyOne row per customer versionNon-overlapping validity intervals

For historical reporting, join on customer_id and the order timestamp within [valid_from, valid_to). A customer-only join to the history table duplicates orders. Specify whether the metric uses current attributes or order-time attributes before choosing the table.

Acceptance check: an order matches exactly one dimension version, including at a validity boundary.

Interactive Check

Question: Should customer country live in fct_orders or dim_customers?

Reveal the answer

Usually dim_customers owns customer country. fct_orders can join to it for analysis, but the descriptive customer attributes belong in the customer dimension.

Practice: Design an Ecommerce Mart

Create a simple star schema with fct_orders, dim_customers, and dim_products.

Use the guided lab below to record your result, assumptions, and the check that would catch an incorrect result.

Production notes

Keep these close

  • Name marts based on business concepts, not source systems. Business users do not care which app emitted the raw table.

Common mistakes

What usually breaks

  • Creating one giant flat table for every question
  • Putting measures in dimensions
  • Ignoring slowly changing attributes

Key terms

Vocabulary used in this module

Mart

A business-facing model intended for analytics consumption.

Dimension

A descriptive table such as customers, products, or accounts.

Exercises

Practice inside the lesson

30-45 minutesBeginner to Intermediate

Design an Ecommerce Mart

Create a simple star schema with fct_orders, dim_customers, and dim_products.

  1. List each table grain
  2. Choose primary keys
  3. Choose foreign keys
  4. Choose three measures on fct_orders
  5. Choose five descriptive columns for dimensions

Expected evidence

A short answer, SQL/YAML snippet, or lineage map that can live directly in the course page notes.

Recap

Key takeaways

  • Marts should be easy and safe for downstream consumers
  • Facts and dimensions make reporting grain explicit
  • Star schemas remain useful even in modern warehouses

Related resources

Keep learning across CodersSecret