Four steps, grain first
Kimball's four-step design process has survived three generations of platforms because it forces decisions in the right order:
- Select the business process. Not a department or a report. A process that produces events: taking orders, shipping, counting stock, setting budgets.
- Declare the grain. State exactly what one row means, in a sentence.
- Identify the dimensions. The context that is true for one row at that grain.
- Identify the facts. The numeric measurements that are true for one row at that grain.
For the sample model's sales process: "fact_sales has one row per sales order line." The dimensions that hold a single value at that grain are order date, ship date, customer, product, warehouse (ship-from) and salesperson. The facts are quantity, gross_amount, discount_amount, net_amount and cost_amount. The order number is context too, but it has no attributes of its own, so it stays on the fact as a degenerate dimension.
Write the grain as a sentence before you write a column list. If a proposed column does not have exactly one value at that grain, it belongs in another table.
Mixed grain is the most common modeling bug. Order-level freight copied onto every line row will be summed once per line. Either allocate it to lines with a stated rule, or give it its own order-grain fact.
Fact table types
| Type | One row per | Sample | Measures | Load pattern |
|---|---|---|---|---|
| Transaction | Event | fact_sales (order line) | Mostly additive | Insert; occasional correction updates |
| Periodic snapshot | Entity per period | fact_inventory_daily (product x warehouse x day) | Balances, semi-additive | Insert one full slice per period |
| Accumulating snapshot | Process instance, updated as milestones happen | An order fulfillment fact with ordered, picked, shipped and invoiced dates | Lags, durations, counts | Insert, then update in place |
| Factless | Event or coverage with no numeric measure | Salesperson assigned to territory per month; products on promotion | Counts of rows | Insert |
fact_budget is a plan fact at a coarser grain (month x product category x region). It behaves like a periodic snapshot but does not share the grain of the dimensions it describes, which is why it needs shrunken dimensions. That case gets its own treatment in Conformed dimensions.
Additive, semi-additive, non-additive
Additivity tells you how a fact may be aggregated, and it is the first thing a semantic model author needs to know about each column.
- Additive facts sum across every dimension.
net_amountcan be summed by customer, product, day or all of them. - Semi-additive facts sum across some dimensions but not time.
on_hand_qtysums across warehouses on a given day, but summing it across the days of a month produces nonsense. Month-level inventory is the closing balance (or an average), not a total. - Non-additive facts never sum: ratios, percentages and unit prices. Store the additive components (
net_amount,cost_amount) and compute Margin % at query time.
-- Month-end on-hand by category: filter to the closing day, then sum across products and warehouses
SELECT d.year_month,
p.category,
SUM(f.on_hand_qty) AS closing_on_hand_qty
FROM gold.fact_inventory_daily AS f
JOIN gold.dim_date AS d ON d.date_key = f.date_key
JOIN gold.dim_product AS p ON p.product_key = f.product_key
WHERE d.is_month_end = 1
GROUP BY d.year_month, p.category;
Star or snowflake
| Star | Snowflake | |
|---|---|---|
| Dimension shape | One wide, denormalized table per dimension | Hierarchy levels split into related tables |
| Joins per query | One per dimension | One per level |
| Storage | Repeats hierarchy text (cheap in columnar storage) | Stores each level once |
| Semantic model | Simple filter propagation, fewer relationships | Longer filter chains, more tables to hide |
| Where it fits | Gold and the semantic model | Silver entities, or a shared level used by a coarser fact |
Use a star in gold. Columnar engines compress repeated category and subcategory strings to almost nothing, so the storage argument for snowflaking mostly disappeared with row stores. Normalization still has a home in silver, where entities are kept clean and singular. The one legitimate snowflake-like shape in gold is a shrunken dimension (a category-level table derived from dim_product) for a fact that lives at category grain.
Special-purpose dimensions
Degenerate dimensions
order_number on fact_sales is a dimension with no attributes. Building a dim_order with one column would only add a join. Keep it on the fact, and in the semantic model expose it for drill-through and hide it from casual browsing.
Junk dimensions
Low-cardinality flags and codes (order channel, rush flag, payment terms) clutter a fact and each make a poor dimension on their own. Combine them into one small table, say dim_order_profile, with one row per observed combination and one key on the fact. The sample model does not need one yet; it is the first thing to add when the order header grows flags.
Role-playing dimensions
dim_date plays two roles on fact_sales: order_date_key and ship_date_key. In the warehouse that is one physical table joined twice with aliases. In the semantic model it becomes one active and one inactive relationship, or two copies of the table; Semantic model preparation covers the trade-off.
Bridge tables
When a fact row relates to many members of a dimension (an order credited to two salespeople at 60/40), a bridge table resolves it: bridge_sales_credit with a group key, salesperson_key and an allocation_weight that sums to 1 per group. Measures multiply by the weight to avoid double counting. Bridges are powerful and easy to misuse, so add one only when the many-to-many is real in the business, not an artifact of a messy source.
Surrogate keys and the unknown member
Every gold dimension gets a surrogate key (customer_key) separate from the business key (customer_id). Surrogates make Type 2 history possible (one business key, many versions), insulate the model from source key changes and merges, and give the semantic engine compact integer joins. Date keys are the accepted exception: an integer yyyymmdd date_key is readable and stable.
Each dimension also carries reserved members: -1 for "Unknown" (the source value was missing or did not match) and, where it helps, -2 for "Not applicable" (a line that has not shipped has no ship date). Fact loads resolve to these members instead of dropping rows or writing NULL keys, so totals always reconcile to the source.
INSERT INTO gold.fact_sales
(order_date_key, ship_date_key, customer_key, product_key, warehouse_key, salesperson_key,
order_number, line_number, quantity, gross_amount, discount_amount, net_amount, cost_amount)
SELECT
COALESCE(od.date_key, -1),
CASE WHEN s.ship_date IS NULL THEN -2 ELSE COALESCE(sd.date_key, -1) END,
COALESCE(c.customer_key, -1),
COALESCE(p.product_key, -1),
COALESCE(w.warehouse_key, -1),
COALESCE(sp.salesperson_key, -1),
s.order_number, s.line_number,
s.quantity, s.gross_amount, s.discount_amount, s.net_amount, s.cost_amount
FROM silver.sales_order_line AS s
LEFT JOIN gold.dim_date AS od ON od.calendar_date = s.order_date
LEFT JOIN gold.dim_date AS sd ON sd.calendar_date = s.ship_date
LEFT JOIN gold.dim_customer AS c
ON c.customer_id = s.customer_id
AND s.order_date >= c.valid_from AND s.order_date < c.valid_to
LEFT JOIN gold.dim_product AS p ON p.product_id = s.product_id
LEFT JOIN gold.dim_warehouse AS w ON w.warehouse_id = s.warehouse_id
LEFT JOIN gold.dim_salesperson AS sp ON sp.salesperson_id = s.salesperson_id;
Note the customer join: because dim_customer is Type 2, the lookup is point-in-time, finding the version that was valid on the order date. The other dimensions are Type 1 in the sample, so a plain business-key match is enough.
Fabric Warehouse has added IDENTITY columns (bigint, unique but not guaranteed contiguous); check that your workspace has them before relying on them. The portable approach in both Warehouse and Spark is MAX(existing key) + ROW_NUMBER() inside the load transaction. Either way, keep keys as integers: VertiPaq compresses and joins integer keys far better than long strings or binary hashes, which matters for Direct Lake memory.
Hash-based surrogate keys (a 64-bit hash of the business key and version) remove the need for a sequence and parallelize nicely in Spark, but they are wide, random and collision-prone if truncated carelessly. Are they worth it for a lakehouse feeding Direct Lake? The deciding factor is whether you load dimensions in parallel across engines.
The Star schema explorer shows each sample fact at its grain with its dimensions and the role-playing date, and the Bus matrix lays out which dimensions each fact shares.