Levels of Aggregation
Context: FIT3003_MOC Β· the ladder of star schemas over ONE subject β how far the fact measure has been rolled up, and how to push it back down β Star Schema, Identifying a Level-0 Star Schema, Fact Constellation Parent Framework: Data Warehouse
Quick Revision
- π― Objective: a warehouse is precomputed aggregate values β keep the same subject at several granularities, (no aggregation, most detail) up to (most aggregated), so management can drill down by querying the level below.
- π¦ Core Components: add a new dimension β breaks each measure value across the new dimensionβs members | replace a dimension with a higher-granularity one β breaks it across finer members of the same axis.
- β‘ Key Constraint: given a star schema you can only decide Level-0 or not β any other number depends on how many non-Level-0 schemas sit beneath it, so the numbering is a property of the architecture, never of one diagram.
π How It Works
1. Granularity and aggregation are inverse
- Level-0 definition β highest granularity, no aggregation: all domain tables are incorporated as dimension tables and no grouping exists in the dimension attributes.
- Inverse pairing β lower granularity higher aggregation higher level number; because warehousing is about aggregates, the ladder is named Level of Aggregation.
- Only one rule β is more aggregated than . There is no guideline on how many levels a warehouse needs, and more than one star schema may sit at the same level.
- A date dimension may not reach Level-0 β Oracleβs
datedisplays only the date portion, so two orders placed by one customer on one day collapse into a single fact row; a true Level-0DateDIMmust store the full date and time to separate them β Identifying a Level-0 Star Schema. - The measure betrays the level β
Num_of_Loginsiscount(*)over theLABACTIVITIEStransaction table grouped by Semester, TimePeriod and Degree β acountin the build SQL proves the schema is not Level-0 β Building Fact Tables.
2. The two ways to lower a level (the only two)
- Add a new dimension β each measure value is literally broken into one value per record of the new dimension; Computer Lab adds and the Level-2 schema becomes Level-1, answering who contributed to the total.
- Replace with a higher-granularity dimension β swap and ; the same measure now sits at the actual login date and time, giving Level-0.
- A replacement can absorb two dimensions β lowering may reduce the dimension count, e.g. a that captures both Order Date and Ordering Method β Identifying a Level-0 Star Schema.
- Count the aggregated dimensions first (Lab 8a) β scan the Level- star for dimensions that bucket something finer (Season buckets dates, Location buckets customers); a dimension already at its finest (Ordering Source) is not a candidate. Level-1 lowers one of them, Level-0 lowers them all.
- Level-1 has no unique answer β the lab marks any schema strictly below Level-2 and strictly above Level-0 as correct; the verdict for Level-0 is the strict one β check that the fact measure carries no aggregation at all.
- Design starts high, not low β a Level-0 schema holds the same data as the operational database, only restructured, which makes βwhy build a star at all?β unanswerable; start where the measures are obviously aggregates and lower from there.
3. Levels are a partial order, not a chain
- Incomparable siblings β Level-1a keyed on and Level-1b keyed on : is finer than but is coarser than β neither is more general.
- What is still decidable β both are strictly below Level-2 and strictly above Level-0, so they share a level number without being comparable.
- The exam question is binary β for any two schemas, answer β is more general than β or βnot comparableβ; never invent a ranking β Fact Constellation.
4. Facts without fact measures
- All-ones measure is redundant β at Level-0 a
countmeasure is on every row, so the measure may be dropped entirely; then holds nothing but its composite key. - Precondition: the measure must be a count β a
summeasure such asTotal_Salesstill carries a per-transaction amount at Level-0 and cannot be removed. - Merging dimensions does not change granularity β folding and into one keyed on
LoginNokeeps Level-0, because there is exactly one login perLoginNo. - The star is an -ary relationship β the measure-less Level-0 fact contains all the information of the E/R diagram, restructured: dimensions entities, fact the transaction relating them.
5. Implementation
- Level-0 is physical, upper levels are derived β Level-0 is built with
create table; the upper-level star schemas are normally implemented as views over it. - The top level is the dashboard β the most aggregated schema is what an interactive management dashboard reads.
- Build direction follows activity (W11) β a passive warehouse is often easier top-down (start at Level-2, lower step by step); an active one must be bottom-up, each level maintained from the one immediately below β Active Data Warehousing.
ποΈ Schema
Mermaid β the Level-0 fact, measure-less, with the merged Lab Activities dimension
erDiagram LABACTIVITIES_DIM ||--o{ COMPUTERLAB_FACT : qualifies COMPUTER_DIM ||--o{ COMPUTERLAB_FACT : qualifies DEGREE_DIM ||--o{ COMPUTERLAB_FACT : qualifies STUDENT_DIM ||--o{ COMPUTERLAB_FACT : qualifies COMPUTERLAB_FACT { NUMBER LoginNo FK NUMBER ComputerID FK VARCHAR2 DegreeCode FK NUMBER StudentNo FK } LABACTIVITIES_DIM { NUMBER LoginNo PK DATE LoginDate DATE LoginTime } COMPUTER_DIM { NUMBER ComputerID PK VARCHAR2 ComputerModel VARCHAR2 ComputerOS VARCHAR2 RoomNumber } DEGREE_DIM { VARCHAR2 DegreeCode PK VARCHAR2 DegreeName NUMBER DegreeDuration } STUDENT_DIM { NUMBER StudentNo PK VARCHAR2 FirstName VARCHAR2 StudyType }π‘ Common Mistake: Keeping
Num_of_Loginsin the Level-0 fact β every row would read ; the count only becomes informative once a level above groups it.
βοΈ Core Decision Matrix
| Method | Trigger condition | Effect on the measure | Effect on the dimension count |
|---|---|---|---|
| Add a new dimension | the needed detail is an entity the fact never referenced (which student, which computer) | each value splits across the new dimensionβs members | |
| Replace with a higher-granularity dimension | the needed detail is a finer version of an existing axis (Semester β LoginDate) | each value splits along the same axis | , or when the replacement absorbs two old dimensions |
When It Flips: replacement is forced once an existing dimension is already at its finest (Order Date and Ordering Method cannot be broken down further) β then only another dimension can be made more detailed.
π Exam Execution Trace & Applied Exercises
Manual Execution Trace β drilling the Computer Lab ladder
| Level | Fact key | Sample row | Measure | Reading |
|---|---|---|---|---|
| Level-2 | Semester, TimePeriod, Degree | S1 Β· 3 Β· BIT | BIT logins at night in S1 | |
| Level-1 | StudentNo | S1 Β· 3 Β· BIT Β· 21002 | one studentβs share; the column must sum to | |
| Level-1a | MonthID, TimePeriod, Degree, Student | May Β· 3 Β· BIT Β· 21002 | that studentβs May night logins | |
| Level-1b | Semester, HourID, Degree, Student | S1 Β· 6:00β6:59pm Β· BIT Β· 21002 | the same student, by hour, not comparable with Level-1a | |
| Level-0 | LoginDate, LoginTime, Degree, Student | 4-Apr Β· 19:00 Β· BIT Β· 21002 | one actual login β the measure is droppable |
- The reconciliation check β every drill-down must preserve the total: Level-1 rows under a Level-2 cell that cell. A mismatch means the lower fact was built from a different join, not a finer grouping.
Applied Exercise 1 β Clothing Company (Lab 8a, Case Study 1)
Problem: the Level-2 star is over , and . Source tables: CUSTOMER1, ORDER1, ORDER_INV1, INVENTORY1, ITEM1. Draw Level-1 and Level-0.
Attempt both levels cold, then expand.
Model answer
- Aggregated dimensions: (buckets order dates) and (buckets customers by city); is already at its finest.
- Level-1 β lower exactly one: with replaced by . Lowering instead is equally acceptable.
- Level-0 β lower both: with β moves inside the customer dimension, so disappears.
- Key move: the number of dimensions is unchanged at Level-1 and Level-0 here β a replacement, never an addition, because both offenders are coarse versions of axes the fact already has.
- β οΈ only reaches Level-0 if it carries the time as well; on a bare Oracle
datetwo same-day orders from one customer still merge.
Applied Exercise 2 β Toll Way (Lab 8a, Case Study 2)
Problem: a toll way records, per passage, the gate, registration number, vehicle type, amount paid, and date/time. Management wants revenue drilled down by toll gate, day of week and time period of a day. Draw Level-2, Level-1 and Level-0.
Write all three, then expand.
Model answer
- Level-2 β the three required axes, all bucketed: over , and β day of week, not the date; time period, not the clock time.
- Level-1 β add a dimension: with ; the grain is the type (car, bus, truck), not the registration number, and the other three dimensions are untouched.
- Level-0 β replace all three: with , and β actual date, actual time, actual vehicle.
- Key move: this case uses both lowering methods β addition to reach Level-1 (vehicle type was never an axis), replacement to reach Level-0 (each existing axis had a finer version waiting in the source).
- Why
Total_Paymentsurvives to Level-0: it is asum, not acount, so it keeps a real per-passage amount and cannot be dropped.
β οΈ Common Mistakes
- π‘ βIt has all the detailed dimensions, so it is Level-0β β lowest-level dimensions do not guarantee an unaggregated measure; the E/R transaction decides β Identifying a Level-0 Star Schema.
- π‘ Numbering a schema from its own diagram β only βLevel-0 or notβ is visible locally; everything else is relative to the schemas built below it.
- π‘ Ranking two same-level schemas β if one dimension is finer and another is coarser, they are incomparable β asserting an order is a mark-loss answer.
π§ Active Recall
The Computer Lab star has Semester, Time Period and Degree dimensions and one measure. Management wants the breakdown of a figure. What do you build, and which method do you use first?
Answer
- Short answer: build a lower level β first add , then replace Semester and Time Period with Login Date and Login Time.
- Why: Drill-down is a query against a lower level β the existing fact physically stores only the rolled-up value, so the detail must exist as another star schema. Addition is the cheaper move β comes from a table already in the operational database and answers βwhoβ, splitting into per-student counts that must re-sum to . Replacement is the deeper move β only swapping reaches the actual date and time, where the measure degenerates to and the fact may drop it.
Level-1a is keyed on Month and Time Period; Level-1b on Semester and Hour. Which has the higher level of aggregation?
Answer
- Short answer: neither β they are not comparable.
- Why: Comparability needs agreement on every axis β is finer than but is coarser than , so the two schemas disagree in opposite directions. The bounds still hold β both are below the Semester/TimePeriod Level-2 and above the LoginDate/LoginTime Level-0, which is why they share a level number. Generalises to the lattice β with two hierarchies the levels form paths, not a chain β Fact Constellation.