Combining Star Schemas

Context: FIT3003_MOC · the reverse question to Multi-Fact Star Schemas — two stars already exist and look alike, may they become one? ➔ Determinant Dimensions, Pivoted Fact Tables Parent Framework: Multi-Fact Star Schemas

Quick Revision

  • 🎯 Objective: classify the pair by how many pools of personnel/objects feed it and whether they share a transaction record ➔ the class dictates which of the three solutions (normal dimension · pivoted fact · type dimension) are legal.
  • 📦 Core Components: one pool, same record ➔ Flight Charter, all three legal, base dimension is determinant | one pool, different records ➔ Bachelor/Master, all three legal, base dimension is normal | two pools, different records ➔ Lecturer/Tutor, only the base solution works.
  • ⚡ Key Constraint: combining is refused outright when the dimension sets differ; the hard cases are the ones where all but one dimension matches, or matches with a different context.

📝 How It Works

1. The easy verdicts

  • Different dimensions never combine ➔ star-1 over and star-2 over are different subjects by definition ➔ Multi-Fact Star Schemas.
  • Same dimensions, different measures join ➔ one subject; merge on the full composite key (Private Taxi).
  • Same dimensions, same measures the difference is the time period ➔ the facts are union-compatible, so union merges them.
create table PrivateTaxiFact1 as
select * from PrivateTaxiFact1a
union
select * from PrivateTaxiFact1b;      -- two periods, identical column lists

2. The hard case and its three options

  • Shape of the problem ➔ star-1 over and star-2 over where and are the same dimension in a different context, or only slightly different.
  • Option 1 — determinant-dimension solution ➔ combine, but the shared dimension becomes a determinant dimension (dashed box).
  • Option 2 — non-determinant solution ➔ combine with an ordinary dimension; no query constraint is created.
  • Option 3 — mutually exclusive ➔ the two populations never meet, so combining is trivial and only the base shape survives.
  • The classifier ➔ count the pools (of personnel or objects) and ask whether they appear in the same transaction record.

3. One pool, SAME transaction record — Flight Charter

  • The case ➔ pilots in one Employee pool; a medium aircraft flight records a pilot and a co-pilot on the same flight row.
  • Naive union fails ➔ select * from FlightCharterFact1 union select * from FlightCharterFact2 then group by TimeID, AircraftNo, EmployeeID — correct per employee, double-counted per month and per aircraft ➔ see the trace.
  • Solution 1 (base) ➔ keep one but mark it determinant: every query must name the pilot/co-pilot role.
  • Solution 2 (pivot) ➔ — measures roles ➔ Pivoted Fact Tables.
  • Solution 3 (type dimension) ➔ pull the pivot back out as ; PilotType joins the fact’s key, measures return to .

4. One pool, DIFFERENT transaction records — Bachelor/Master Projects

  • The case ➔ one pool of Faculty Members; two transaction tables (Bachelor projects, Master projects) but one manager per project, so no row carries two roles.
  • No determinant dimension arises ➔ nothing is double-counted, so stays a normal (solid-box) dimension.
  • Same three solutions ➔ base · pivot into Num_of_Bachelor_Projects, Num_of_Bachelor_Students, Num_of_Master_Projects, Num_of_Master_Students · or add with LevelNo in the fact key.
  • The originals can be discarded ➔ unlike the Flight Charter case, once combined there is no reason to keep the two source stars.

5. Two pools, DIFFERENT transaction records — Lecturer/Tutor

  • The case ➔ two distinct pools (Tutors/TAs and Faculty Members); each tutorial has exactly one teacher drawn from either pool.
  • Only the base solution works ➔ a single holding both pools, carrying only attributes common to both (StaffNo, Name, Office, Phone).
  • Pivot is nonsense ➔ for a tutor there is no Num_of_Classes_by_Lecturer, and vice versa — every row would be half zeroes by construction.
  • A type dimension is nonsense ➔ there is no Lecturer Tutor-Type combination to key on.
  • Two separate dimensions are worse ➔ one dimension per pool leaves each fact measure without values for the other.
  • If a type is genuinely needed ➔ add a Type attribute inside ; it describes the staff record, it is not an analysis axis.

⚖️ Core Decision Matrix

CasePoolsTransaction recordsBase dimensionPivot legal?Type dimension legal?Keep originals?
Flight Charter (pilot / co-pilot)onesame row holds both rolesdeterminant (dashed)✅✅✅ — the combined fact is only safe under the determinant rule
Bachelor / Master projectsonedifferent rows, one role eachnormal (solid)✅✅❌ — combined star fully replaces them
Lecturer / Tutor tutorialstwodifferent rows, one role eachnormal, common attributes only❌ half the row is structurally empty❌ no valid combination exists❌

When It Flips: the determinant requirement appears exactly when one transaction row contributes the same measure to two members of the same pool — that is the sole source of the double count, and it is why Bachelor/Master escapes it despite also being one pool.

📊 Exam Execution Trace & Applied Exercises

Manual Execution Trace — where the Flight Charter union breaks

PerspectiveEmployee 101 as pilotEmployee 101 as co-pilotCombined totalCorrect?
per employee, Jan, A1 h h h✅ 101 really was aboard for h
per aircraft A1, Jan h h counted again under the other pilot h❌ each two-crew flight counted twice
per month Janas aboveas aboveinflated❌ same double count
per employee and PilotType h h, separate rowcorrect per role✅ the determinant attribute is pinned
  • Reading the trace ➔ the error is invisible from the employee axis and only surfaces on the aircraft and month axes — which is exactly why the constraint must be structural, not documented ➔ Determinant Dimensions.

Applied Exercise — classify and prescribe

Problem: a hospital records each operation with a surgeon and an assisting surgeon on the same operation row, both drawn from the one Doctor pool. Two stars exist (Surgeon, Assistant) over with measures Total Hours and Total Cost. Combine?

Final Extracted Output: combine, but only with one of the three enforced shapes — dashed , a pivoted fact, or a keyed into the fact; a plain union group by inflates every theatre and month total.

⚠️ Common Mistakes

  • 💡 Merging identical-looking stars with union alone ➔ union de-duplicates rows, it does not re-aggregate; the outer group by is what merges, and it is legal only when no transaction row feeds two members ➔ Multi-Role Facts.
  • 💡 Applying the pivot or type-dimension solution to the two-pool case ➔ both produce structurally empty measures or impossible key combinations; the mutually-exclusive case has one solution.
  • 💡 Putting the type inside the dimension when it is an analysis axis ➔ a Type attribute in describes staff; a keyed into the fact splits measures. The Lecturer/Tutor case needs the first, the Bachelor/Master case the second.

🧠 Active Recall