Chapter 9

Multidimensional warehousingDA

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 schemasDA

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.

SchemaArrangementConsequence
StarFact table directly references denormalised dimension tablesFewer dimension joins; descriptive redundancy
SnowflakeDimension attributes split into normalised hierarchy tablesLess repeated description; more joins
Fact constellationSeveral fact tables share dimensionsRelated 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.An original star schema at product–depot–day grain; arrows denote fact-table foreign keys.

9.2 Concept hierarchies and OLAP operationsDA

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.

OperationChange to the view
Roll-upAggregate to a coarser level or remove a dimension
Drill-downMove to more detail or introduce a dimension
SliceFix one dimension to a member, reducing displayed dimensionality
DiceRestrict a subcube using sets/ranges on several dimensions
PivotReorient the display; underlying facts are unchanged
Drill-throughInspect 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 countsDA

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 summariesDA

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 classValid aggregationTypical measure
AdditiveSum across every dimension at the stated grainUnits sold, sales amount
Semi-additiveSum across some dimensions onlyEnd-of-day balance across accounts, not across days
Non-additiveDirect sum is not meaningfulPercentage, ratio, unit price
Computation classRequired partial stateExamples
DistributiveCombine the same aggregate from partitionsSUM, COUNT, MIN, MAX; combine counts by summing
AlgebraicFixed-size collection of component aggregatesAVG from SUM/COUNT; variance from count, sum and sum of squares
HolisticNo fixed-size exact summary independent of the data-domain sizeMedian, 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.

Revise offline: the whole Databases and Data Warehousing handbook as one PDF

58 pages · 2.7 MBFree to read online. Sign in to download the PDF.We save the handbook, version and request time in My downloads. Privacy policy

All chapters · Corrections