A dimensional model (a star schema) splits data into fact tables, which hold measurable events, and dimension tables, which hold the descriptive context you filter and group by. Preparing data for it means reshaping source tables into that form and loading them in a safe order. Fabric Data Warehouse is where you build it with T-SQL.
Shape of each table type
A dimension table has a surrogate key (a meaningless integer generated in the warehouse), the natural key from the source, descriptive attributes, and often audit columns. A fact table has foreign keys to dimensions, numeric measures, and sometimes identifying attributes such as an order number.
Common fact table styles:
- Transaction: one row per event, never changed except to fix errors.
- Periodic snapshot: one row per period, such as an end-of-day stock balance. Its measures are semi-additive.
- Accumulating snapshot: one row per process, updated as milestones are reached, with several date keys.
Surrogate keys
Use the smallest integer type that fits. In a Fabric warehouse an IDENTITY column must be bigint, you cannot choose the seed or increment, values are unique but not guaranteed to be sequential, and gaps appear. Never rely on the order. Do not truncate and reload a dimension that has generated keys, because the keys stored in fact rows would no longer match.
Slowly changing dimensions
- Type 1 overwrites the attribute. No history.
- Type 2 keeps history. Expire the current row (set its end date and set the current flag to false), then insert a new row with a new start date and the flag true.
- Type 3 keeps limited history in extra columns.
-- Type 2 in two steps: expire, then insert
UPDATE dbo.DimCustomer
SET ValidTo = SYSDATETIME(), IsCurrent = 0
FROM dbo.DimCustomer d
JOIN stg.Customer s ON s.CustomerID = d.CustomerID
WHERE d.IsCurrent = 1 AND s.City <> d.City;
INSERT dbo.DimCustomer (CustomerID, City, ValidFrom, ValidTo, IsCurrent)
SELECT s.CustomerID, s.City, SYSDATETIME(), NULL, 1
FROM stg.Customer s
LEFT JOIN dbo.DimCustomer d
ON d.CustomerID = s.CustomerID AND d.IsCurrent = 1
WHERE d.CustomerID IS NULL;
Source deletions should normally become a soft delete, a bit column such as IsDeleted, not a physical delete, because facts may still point at the row. Reports then filter those rows out.
Special members and the date dimension
Add rows for missing, unknown, not-applicable and error states, using fixed keys such as 0, -1, -2 and -3. A failed lookup during a fact load should map to Unknown instead of dropping the fact row.
The date dimension has no source system, so you generate it. Use a date natural key and an integer surrogate in YYYYMMDD form. Extend it forward each year, and rerun daily if it has relative-offset columns such as "previous month". If you analyse time of day, add a separate time dimension and a second key in the fact table.
Load order
- Optionally land the data in staging tables.
- Load dimensions.
- Load facts, looking up each surrogate key. For an SCD Type 2 dimension, take the key of the current version.
- Do post-processing, such as refreshing a semantic model.
Loading options include COPY INTO for Parquet or CSV in external storage, pipelines, dataflows, and cross-warehouse statements such as INSERT...SELECT and CREATE TABLE AS SELECT.
An inferred member is a dimension row that a fact load creates when it meets a natural key the dimension has not seen yet. It carries Unknown attributes and an inferred flag; when the real details arrive, update the row in place instead of treating it as a Type 2 change.
Common mistakes
- Relying on foreign key enforcement. The warehouse does not enforce foreign keys, so the load itself must check integrity.
- Truncating and reloading a fact table when an incremental load (a high watermark or CDC) would do.
- Putting time of day into the date dimension.
- Using meaningful business keys as the warehouse key.
For the exam
- Load dimensions before facts.
- Surrogate keys:
bigint IDENTITY, unique, gaps possible, no custom seed. - Type 1 overwrites; Type 2 adds a row and expires the old one.
- Handle deletions as soft deletes; use special members for unknown lookups.
- Foreign keys are not enforced, so validate in the ETL.