Saltar al contenido

Lección 8 · Dimensional Modeling

Conformed Dimensions and the Bus Matrix

Learn how conformed dimensions let you combine fact tables safely, how to plan with a bus matrix, and how to drill across two stars in SQL.

One star answers questions about one process. The interesting questions often cross processes: "Which categories sell well but are often returned?" To answer them correctly, the stars must speak the same language. That is the job of conformed dimensions.

What conformed means

A dimension is conformed when different fact tables use it with the same meaning. The simplest case is one shared physical table, such as dim_product, used by sales, returns and inventory.

Conformed dimensions can also be shrunken: a smaller version with fewer rows or columns, such as a month dimension derived from the date dimension, or a category dimension derived from products. It conforms when its shared attributes have identical names, values and meanings.

If sales calls a category "Footwear" and returns calls it "Shoes", you cannot reliably compare them, whatever the SQL does.

The bus matrix

The bus matrix is a planning grid. Rows are business processes, columns are dimensions, and a mark shows which dimensions each process uses.

Business process Date Product Store Customer Supplier Promotion
Retail sales X X X X X
Returns X X X X
Store inventory X X X
Purchase orders X X X

It is a small artifact with a large effect:

  • Columns with many marks are the dimensions that most need shared ownership.
  • Rows are natural units of delivery: build one process at a time.
  • Gaps show which comparisons are possible. You cannot analyze inventory by customer.

Add columns for the process owner and source system when it helps.

Drilling across

Combining measures from two fact tables is called drilling across. Do it in two stages:

  1. Query each fact table separately, grouped by the same conformed attributes.
  2. Join the two result sets on those attributes.
SQL Drill across sales and returns safely

Press Run (or Ctrl + Enter) to see the result here.

The correct totals for Footwear are 35 sold and 3 returned. The wrong query reports 30 sold and 6 returned: sandals vanish because they have no returns, and boot rows are paired with every boot return. Both errors are silent.

The right query starts from sales with a LEFT JOIN. If a category could have returns without sales in the period, use a full outer join or build the list of categories from both results.

Also note that returns often happen later than the sale. A "return rate" by month compares returns made that month with sales made that month, unless you link each return to its original sale. State which definition you use.

Governing shared dimensions

A conformed dimension is an agreement between people. Decide:

  • Who owns it. One group approves changes to attributes and definitions.
  • Which source wins when systems disagree about a value.
  • How changes are announced, because many reports depend on it.
  • Which keys it publishes. All fact loads use the same surrogate keys.

Matching the same real-world customer or product across systems is the hard part. Large organizations sometimes manage it as master data management (MDM): processes and tools that keep a trusted record for core entities.

When conformance is partial

You rarely get everything aligned at once. It is fine to conform the most used attributes first, as long as you document the rest. Do not give two different things the same column name. If two teams really mean different things by "region", call them sales_region and shipping_region.

Conforming a dimension step by step

Imagine two sources with their own product lists: the point-of-sale system and the warehouse management system. Making one conformed product dimension typically involves these steps:

  1. List the attributes each source has, with examples of real values.
  2. Choose a matching rule. A shared manufacturer barcode may help, but check for missing, reused or mistyped codes.
  3. Create a mapping table from each source identifier to one warehouse product.
  4. Pick the winning source for each attribute. The sales system might own the display name and the stock system the package size.
  5. Standardize values, such as one spelling for each category.
  6. Report the leftovers. Records that cannot be matched go on a list that a person reviews.

Never force a doubtful match just to make the totals tidy. A wrong merge mixes two products' history and is hard to undo.

Shrunken dimensions in practice

Suppose targets are set per category and month, while sales are recorded per product and day. The target fact table cannot point to a product or a day. It points to a category dimension and a month dimension instead. Because their values are derived from the product and date dimensions, you can drill across: summarize sales to category and month, then join to targets.

SQL
-- Read-only: compare at the level that both tables share
SELECT t.month, t.category, s.revenue, t.target_amount
FROM target_by_category_month t
LEFT JOIN sales_by_category_month s
  ON s.month = t.month AND s.category = t.category;

You cannot go the other way and spread a category target over products without inventing an allocation rule. If the business has such a rule, apply it explicitly and label the result as allocated.

Using the matrix to plan work

When choosing what to build first, weigh two things for each row of the bus matrix: how valuable the answers are, and how hard the data is to get. A process with high value and a well-understood source is a good start. Building it creates the date, product and store dimensions, which makes later rows cheaper. Update the matrix as you learn, and show it to business users. It is one of the few warehouse documents that people outside the data team can read at a glance.

Common mistakes

Copying a dimension into each mart and letting each copy evolve is the fastest way to lose conformance. Build shared dimensions once and publish them to every star that needs them.

Check your understanding

Quick check · 3 questions

of 3 answered You scored / 3 · perfect!

  1. 1. What makes a dimension conformed?

    Consistent names, values and meaning let results from different stars line up.
  2. 2. What do the rows and columns of a bus matrix show?

    It is a plan of processes against shared dimensions.
  3. 3. What is the safe way to compare measures from two fact tables?

    Pre-aggregating prevents rows from multiplying each other.

Summary

  • Conformed dimensions give separate fact tables a shared vocabulary.
  • A bus matrix plans processes, dimensions and delivery order.
  • Drill across by aggregating each fact table before joining.
  • Shared dimensions need clear ownership and change rules.

Next: Fact Table Types

Tu progreso se guarda en este navegador. No necesitas una cuenta.