skip to content

What is a shrunken conformed dimension, and what rule must it obey?

level: seniorimportance: nice to knowfreq 28%

answer

  1. not every fact exists at the atomic grain
  2. budgets and forecasts arrive coarser
  3. rolled up, never independently sourced
  4. its attributes must be a strict subset
  5. its columns are the shared vocabulary

basics

~20 s

A shrunken conformed dimension is a coarser version of a base dimension - fewer rows and fewer attributes - serving a fact table at a higher grain. It conforms only if its attributes are a strict subset of the base dimension's, carrying identical names and identical values.

solid answer

~50 s

Some fact tables simply do not exist at the atomic grain. A sales forecast may be produced per brand per month while actual sales are recorded per product per day. You cannot point the forecast fact at the day-grain date dimension or the product-grain product dimension, so you build rolled-up versions: a month dimension and a brand dimension. These are **shrunken conformed dimensions**, and the conformance rule is strict subsetting - every attribute they carry must also exist in the base dimension, under the same name, with the same values, and the rows must be an exact rollup of the base rows with no locally invented members. If the month dimension invents a fiscal-period label the date dimension does not have, or classifies a brand differently, conformance is gone. Get it right and forecast and actuals drill across cleanly on the shared attributes.

code

sql · 16 lines
sql
-- Strict subset of dim_date's attributes, exact row rollup
CREATE TABLE dim_month AS
SELECT DISTINCT
       year_month AS month_key,
       year_month,
       calendar_quarter,
       calendar_year,
       is_fiscal_close
FROM dim_date;

-- Standing conformance test: must return zero rows
SELECT d.date_key
FROM dim_date d
JOIN dim_month m ON m.month_key = d.year_month
WHERE m.calendar_quarter <> d.calendar_quarter
   OR m.calendar_year    <> d.calendar_year;

go deeper

for a junior

Know the idea exists: some facts, like budgets or forecasts, arrive at a coarser grain and need a rolled-up version of a dimension rather than the atomic one.

for a middle

Explain the strict-subset rule - same attribute names, same values, rows an exact rollup - and be able to say which day-level attributes cannot survive a shrink to month grain.

for a senior

Show how you would build it by derivation from the base dimension and back it with a standing test, and describe how an independently loaded coarse dimension turns a modelling error into an apparent business variance.

for a principal

Own the consequence for the estate: the shrunken dimension's attribute list is the shared vocabulary between two processes, so what it carries determines what the business can compare across grains.

## Why a coarser dimension is ever needed A conformed dimension is usually shared as-is: two fact tables both reference `dim_product`, both at product grain. But not every business process produces facts at the atomic grain of the dimension. Budgets are set at brand and month. Forecasts are made at region and quarter. Aggregate fact tables deliberately summarise to a coarser level. A fact row at brand-month grain cannot carry a product key or a day key, because it does not correspond to one product or one day. The answer is a **shrunken conformed dimension**: a dimension rolled up to the coarser level, with its own key, fewer rows and fewer attributes than the base dimension it derives from. ```text dim_date (day grain) -> dim_month (shrunken) date_key month_key full_date year_month year_month calendar_quarter calendar_quarter calendar_year calendar_year is_fiscal_close day_of_week is_weekend ``` The shrunken `dim_month` keeps only attributes that are *well defined at month grain*. Day of week and weekend flag are dropped because they have no month-level value; year, quarter and fiscal-close flag survive because every day in a month agrees on them. ## The conformance rule The rule is strict subsetting, and it has three parts: 1. **Attribute subset.** Every attribute of the shrunken dimension must also exist in the base dimension, under the **same name**. No locally invented columns. 2. **Value identity.** For any base row, the value of a shared attribute must be identical to the value on the shrunken row it rolls up to. If `dim_date` says a date is in `2024-Q1`, the month row containing it must also say `2024-Q1`. 3. **Row rollup.** The shrunken dimension's rows must be exactly the distinct rollup of the base rows - no extra members, no members that combine base rows the base dimension does not group together. If all three hold, the shrunken dimension is conformed to the base, and facts keyed by either can be drilled across on the shared attributes. ## Why the rule is not merely pedantic Breaking it produces the same silent wrongness as any conformance failure, but harder to spot because the shrunken dimension is small and looks obviously correct. Two concrete failures: **A locally invented attribute.** Someone adds `season` to `dim_month` because the forecast team wants it, and never adds it to `dim_date`. Now a forecast can be reported by season and actuals cannot, so the comparison the whole design existed to enable is impossible for that attribute - and worse, if `season` is later added to `dim_date` with a different boundary rule, the two disagree. **A divergent classification.** The base product dimension assigns a product to brand `Atlas`; a separately built brand dimension, loaded from a different source, assigns the brand to a different parent group. Forecast at brand level and actuals rolled up from product level then disagree on totals, and the difference looks like a forecasting error rather than a modelling error. ## How to build it so it stays conformed The safest construction is to derive the shrunken dimension **from** the base dimension rather than loading it independently: ```sql CREATE TABLE dim_month AS SELECT DISTINCT year_month AS month_key, year_month, calendar_quarter, calendar_year, is_fiscal_close FROM dim_date; ``` Deriving guarantees value identity and row rollup by construction, and it makes the subset relationship literal - the column list *is* the subset. Loading the coarse dimension from a separate source is where divergence enters, and it is worth resisting even when a source system offers a convenient month or brand table. A continuous test is cheap and worth having: for each shared attribute, check that no base row disagrees with the shrunken row it rolls up to. ```sql -- Must return zero rows SELECT d.date_key FROM dim_date d JOIN dim_month m ON m.month_key = d.year_month WHERE m.calendar_quarter <> d.calendar_quarter OR m.calendar_year <> d.calendar_year; ``` ## Drilling across the grain gap Once conformed, a fact at month grain and a fact at day grain combine the normal way: aggregate the daily fact up to the coarser attributes both dimensions carry, aggregate the monthly fact by the same attributes, and align the two summaries. The join surface is precisely the intersection of the attribute sets - which, because of the subsetting rule, is just the shrunken dimension's attribute list. That is the practical reason the rule matters: the shrunken dimension's columns *are* the vocabulary the two processes can talk about together, so anything it invents privately is vocabulary no one can answer in.

  • Why derive a shrunken dimension from the base dimension rather than loading it from the source system?
    Deriving guarantees value identity and row rollup by construction - the column list literally is the subset and no row can disagree with its parent. An independently loaded coarse dimension can classify members differently or carry different labels, and the resulting mismatch surfaces as an apparent business variance between the coarse and fine fact tables rather than as an error.
  • Which attributes get dropped when you shrink a day-grain date dimension to month grain?
    Anything not well defined for a whole month: day of week, weekend flag, holiday flag, the date itself. What survives is what every day in the month agrees on - year, quarter, fiscal period, month name. The test is whether all base rows rolling into one coarse row share a single value for the attribute; if they do not, it cannot be carried up.
  • How do you test continuously that a shrunken dimension is still conformed?
    Join the base dimension to the shrunken one on the rollup key and assert that every shared attribute agrees, expecting zero rows back. Add a second check that the shrunken dimension's member set is exactly the distinct rollup of the base members, so neither extra nor missing rows creep in as the base dimension grows.

saying these in an interview costs you the question

  • Adds an attribute to the shrunken dimension that the base dimension lacks
  • Loads the coarse dimension independently from a source system
  • Thinks any smaller dimension counts as a shrunken conformed one
  • Carries day-level attributes up into a month-grain dimension
  • Assumes conformance is guaranteed because both tables share a key name

context