Multi-Fact Star Schemas

Context: FIT3003_MOC Β· one schema, several fact tables β€” the answer when one fact cannot legally hold every measure βž” Star Schema, Building Fact Tables, Combining Star Schemas Parent Framework: Star Schema

Quick Revision

  • 🎯 Objective: a warehouse is Subject-Oriented βž” one star schema focuses on one subject only; a second fact table is created for exactly two reasons β€” a different subject or a different granularity.
  • πŸ“¦ Core Components: different subject βž” Book Sales vs Review β€” the applicable dimension sets differ | different granularity βž” Car Service β€” Service grain vs Part grain.
  • ⚑ Key Constraint: the dimensions identify the subject, not the unit of measure β€” kilometres, litres and dollars measured against the same three dimensions are ONE fact with three measures, never three facts.

πŸ“ How It Works

1. When a second fact is justified

  • Four warehouse features βž” Integrated Β· Subject-Oriented Β· Time-Variant Β· Non-Volatile; the second one is what forces the rule.
  • Two causes only βž” (i) different subject, (ii) different granularity; a measure being in different units is not a cause.
  • Dimensions are shared, not duplicated βž” both facts hang off the same tables wherever they apply; only the set of applicable dimensions differs.
  • Where the granularity cause comes from (W8) βž” materialising a dimension hierarchy as one fact per level is the systematic source of granularity multi-facts; two hierarchies give facts and the whole thing is a Fact Constellation βž” Fact Constellation, Dimension Hierarchies.

2. The subject test β€” the measure dimension applicability grid (Book Sales)

  • Method βž” cross every candidate fact measure with every candidate dimension and ask whether the pairing answers a sensible business question; a measure that fails a dimension cannot sit in that dimension’s fact.
  • Where Num_of_Reviews fails βž” Store (a star rating belongs to the book, not the shop that sold it) and Time (the recorded date is the purchase date, not the review date β€” read off the E/R diagram, not assumed).
  • The split βž” and , sharing and .
  • One rating per book βž” a book receives many reviews, so StarID in the sales fact is the book’s rounded average rating banded into the star dimension, not an individual review.
  • Lab 7 evidence βž” source tables live in the dtaniar account (BOOK5, REVIEW5, SALES5, SALESDETAILS5, …); ISBN 0316465186 is the book with no review, and it is the row that proves the outer join and the nvl(…, 0) both fired.

3. Different granularity β€” Car Service

  • Star-1, Service grain βž” ; reaches it only through a ServiceBridge.
  • Star-2, Part grain βž” β€” finer detail, the bridge disappears, PartNo enters the key.
  • PartDIM must be a determinant dimension βž” one part serves many services, so a query that omits PartNo double-counts Number_of_Services; the star draws it dashed.
  • Total_Service_Cost cannot follow βž” cost is recorded per service, and the E/R diagram gives no per-part cost, so the finer fact carries the count measure only.

βš™οΈ Core Implementation

πŸ”Ή Book Sales β€” the four dimensions

πŸ”Ή The small fact is the easy one

πŸ”Ή The large fact needs one star rating per book first

πŸ”Ή Lab 7 β€” the five reports off a two-fact star

πŸ”Ή Removing a dimension by pivoting the small fact

βš–οΈ Core Decision Matrix

SituationDimension setsCorrect shapeWhy
Book Sales vs Reviews vs two factsa measure is meaningless against a dimension it does not apply to
Private Taxi: km, fuel, income for all threeone fact, three measuresidentical dimension sets one subject; units of measure are irrelevant
Car Service: service vs part vs two factsdifferent granularity; the finer fact needs a determinant PartDIM
Same dimensions, same measures, different periodsidenticalone fact via unionunion-compatible βž” Combining Star Schemas

When It Flips: three separate facts collapse into one the moment their dimension lists are found to be identical β€” the Private Taxi three-fact draft is unreasonable, not merely inefficient.

πŸ“Š Exam Execution Trace & Applied Exercises

Manual Execution Trace β€” the Book Sales applicability grid

DimensionTotal_SalesNum_of_BooksNum_of_ReviewsVerdict
βœ… sales per storeβœ… books sold per store❌ ratings attach to books, not shopssales fact only
βœ… sales per monthβœ… books per month❌ the stored date is the purchase datesales fact only
βœ…βœ…βœ… reviews per categoryboth facts
βœ… sales of -star booksβœ…βœ… -star reviews per categoryboth facts
  • Reading the grid βž” the rows with a ❌ are what split the schema; the two all-βœ… dimensions are the shared ones and are physically created once.

Applied Exercise β€” is this one subject or three?

Problem: the Private Taxi warehouse has , , and the measures Total Kilometres, Total Fuel Used, Total Income. A draft proposes one fact per measure. Decide, then write the merge.

create table PrivateTaxiFact as
select F1.CarNo, F1.WeekNo, F1.DriverNo,
       F1.Total_Kilometers, F2.Total_Fuel_Used, F3.Total_Income
from   PrivateTaxiFact1 F1, PrivateTaxiFact2 F2, PrivateTaxiFact3 F3
where  F1.CarNo = F2.CarNo and F1.CarNo = F3.CarNo
and    F1.WeekNo = F2.WeekNo and F1.WeekNo = F3.WeekNo
and    F1.DriverNo = F2.DriverNo and F1.DriverNo = F3.DriverNo;

Final Extracted Output: one fact, three measures β€” ; splitting it again later is a vertical slice, not a modelling decision.

⚠️ Common Mistakes

  • πŸ’‘ Using the unit of measure as the subject test βž” β€œdistance, volume and money are three subjects” is the trap the Private Taxi case is built to catch; only the dimension set identifies the subject.
  • πŸ’‘ Reading applicability off intuition instead of the E/R diagram βž” β€œreviews per month” sounds sensible and is wrong, because the operational schema stores no review date.
  • πŸ’‘ Carrying every measure down to the finer fact βž” Total_Service_Cost at Part grain has no defensible value; a measure only descends if the source can attribute it at that grain.

🧠 Active Recall