Multidimensional warehousing
A warehouse organises integrated historical data for analysis. Start with the grain of the fact table, then identify dimensions, hierarchy levels and legal aggregations. The same arithmetic can be valid for sales flows and invalid for account balances across time.
9.1 Fact grain and warehouse schemas
The grain says exactly what one fact row represents: for example, one item on one invoice, or one product–store–day summary. Dimension keys identify descriptive context; measures record observations at that grain. A key composed only of dimensions is unique only if the declared grain ensures one row per such combination. A transaction identifier may also be needed.
| Schema | Arrangement | Consequence |
|---|---|---|
| Star | Fact table directly references denormalised dimension tables | Fewer dimension joins; descriptive redundancy |
| Snowflake | Dimension attributes split into normalised hierarchy tables | Less repeated description; more joins |
| Fact constellation | Several fact tables share dimensions | Related processes can be compared at compatible grains |
A warehouse is subject-oriented, integrates multiple sources, retains time history and is mainly loaded and queried rather than repeatedly overwritten like an operational transaction store. OLTP favours small current-state transactions; OLAP favours scans and grouped summaries. ETL means extract, transform and load. ROLAP stores analytical data in relational structures; MOLAP uses multidimensional structures; HOLAP combines the approaches.
Joining fact tables directly through a dimension can multiply measures when both sides contain several rows per dimension value. Aggregate to a common grain before comparing measures. A factless fact table records an event or relationship whose count is useful even without an explicit numerical measure.
An original star schema at product–depot–day grain; arrows denote fact-table foreign keys.
9.2 Concept hierarchies and OLAP operations
Past papers · DA 2024–2026 (3 papers): 1 question, 1 mark
A concept hierarchy relates detailed members to broader categories. A geography path might be locality→district→state→country→ALL. A time dimension can have alternative paths such as day→month→quarter→year and day→week→year; they are not interchangeable partitions.
| Operation | Change to the view |
|---|---|
| Roll-up | Aggregate to a coarser level or remove a dimension |
| Drill-down | Move to more detail or introduce a dimension |
| Slice | Fix one dimension to a member, reducing displayed dimensionality |
| Dice | Restrict a subcube using sets/ranges on several dimensions |
| Pivot | Reorient the display; underlying facts are unchanged |
| Drill-through | Inspect underlying detailed records behind an aggregate |
Safe sum roll-up needs disjoint child groups, complete coverage and a valid measure aggregation. A strict hierarchy assigns each child to one parent at a level. Multiple parents can double-count unless allocation or distinct-event logic is supplied. Missing levels or non-covering paths also need explicit treatment. Concept generalisation replaces a detailed value with an ancestor; discretisation creates a numerical concept hierarchy by grouping intervals.
9.3 Cuboids, CUBE and ROLLUP counts
Past papers · DA 2024–2026 (3 papers): 2 questions, 4 marks
A cuboid fixes a grouping level in each dimension. The base cuboid is most detailed; the apex has all dimensions at ALL. SQL CUBE(D1,...,Dd) creates every subset of the listed grouping dimensions. ROLLUP(D1,...,Dd) creates only the successive left prefixes, ending with the grand total. List order matters for ROLLUP, but not the set of grouping sets in CUBE.
For sparse facts, the exact CUBE row count is the sum, over grouping sets, of the number of distinct observed grouping tuples, including one grand total. An empty input still has a grand-total row for the empty grouping set, with aggregate-specific null/zero values. Do not apply the dense product formula to sparsity or hierarchy dependencies.
Generated subtotal positions are displayed as nulls, which can collide visually with genuine null dimension values. GROUPING(column) distinguishes a subtotal placeholder from an ordinary grouped value. Dimensions and hierarchy levels determine cuboid counts; measures do not add another factor merely because several aggregates are selected.
9.4 Measure categories and mergeable summaries
Classify a measure in two independent ways: along which dimensions it can be added, and how much summary state is needed to compute it from partitions.
| Additivity class | Valid aggregation | Typical measure |
|---|---|---|
| Additive | Sum across every dimension at the stated grain | Units sold, sales amount |
| Semi-additive | Sum across some dimensions only | End-of-day balance across accounts, not across days |
| Non-additive | Direct sum is not meaningful | Percentage, ratio, unit price |
| Computation class | Required partial state | Examples |
|---|---|---|
| Distributive | Combine the same aggregate from partitions | SUM, COUNT, MIN, MAX; combine counts by summing |
| Algebraic | Fixed-size collection of component aggregates | AVG from SUM/COUNT; variance from count, sum and sum of squares |
| Holistic | No fixed-size exact summary independent of the data-domain size | Median, mode, exact distinct count over an unrestricted domain |
A fixed finite domain can permit a histogram for exact median or distinct count, but its size grows with the domain. Approximate sketches are a different claim. Averaging means or percentages without denominator weights is generally wrong. For overall rate, sum the compatible numerators and divide by the sum of their denominators.
Last-minute recall
- Declare fact-table grain before deciding its key or summing measures.
- Star denormalises dimensions; snowflake normalises their hierarchy tables.
- Roll-up coarsens; drill-down adds detail; pivot changes presentation.
- A cube's number of grouping sets differs from its total cell count.
- Hierarchy-level counts include ALL when using the product rule.
- Dense cube row counts require every detailed member combination.
- Additivity and distributive/algebraic/holistic classification answer different questions.
- Merge SUM and COUNT to obtain an overall mean; retain squared sums for variance.