Multi-Input Operational Databases

Context: FIT3003_MOC Β· the transformation process when the input is several operational databases and the output is one integrated star schema βž” Data Engineering, Building Fact Tables, Combining Star Schemas Parent Framework: Data Warehouse

Quick Revision

  • 🎯 Objective: build one star schema per source, then stack them βž” Vertical Stacking when the per-source facts are union-compatible (same dimensions, same measures) | Horizontal Stacking when each source owns different measures.
  • πŸ“¦ Core Components: vertical βž” union collapses rows downward | horizontal βž” zero-padded TempFacts union outer sum push every source’s measures into one wider row.
  • ⚑ Key Constraint: union demands union-compatible column lists, so a horizontal stack must project every measure column in every TempFact, filling the ones that source does not own with 0.

πŸ“ How It Works

1. Why multi-input is possible at all

  • Same theme, different schemas βž” the three student clubs store members, activities and financial expenditure in entirely different E/R diagrams β€” one even lives in an Excel workbook β€” but all answer the same two questions.
  • Integration is a warehouse property βž” Integrated is the first of the four warehouse features, and it is what licenses one fact over heterogeneous sources βž” Data Warehouse.
  • Reconcile the measure definition first βž” each source computes TotalIncome differently, so agree the definition before any SQL: ; ; .
  • Qualify the source tables βž” tables are addressed as "ClubName.Table", e.g. "OrchestraClub.Concert", so the same table name in two sources never collides.

2. Vertical Stacking β€” University Student Clubs

  • Shape βž” every source yields the same star: , so the facts stack vertically β€” rows down.
  • Shared dimension, built by union βž” derive a per-source YearDim with select distinct to_char(<date>, 'YYYY'), then union the three and select distinct again; derived attributes (UniversityStartDate/EndDate) are added afterwards with alter table update.
  • Small dimension, hand-built βž” has one row per club and is written with three insert statements, not derived βž” Building Dimension Tables.
  • Stamp the source identity βž” each per-club TempFact gets alter table … add (ClubID integer) then update … set ClubID = n; without it the union loses which club a row came from.
  • Mind the level of aggregation inside a source βž” Concert is coarser than Ticket, so OrchestraTempFact1 is at ticket grain and needs a second group by before the final fact βž” Levels of Aggregation.

3. Horizontal Stacking β€” Real-Estate Property

  • Shape βž” β€” five measures, each owned by a different source, so the facts stack horizontally β€” columns across.
  • Independent sources βž” Inspection DB (listings and inspections) Β· Auction DB (auctions and results) Β· Sold Property DB (completed sales); the same PROPERTY table exists in all three with different attributes, and only the Inspection DB carries ListedDate.
  • Measure ownership βž” Auction DB βž” TotalPropertiesAuction and TotalSuccessfulAuction (filter AuctionResultCode = 'SA') Β· Inspection DB βž” NumNewListing (count grouped on ListedDate) Β· Sold DB βž” TotalPropertiesSold and TotalSoldPrice.
  • Derived indicators are not stored βž” Auction Clearance Rate and mean price are computed at query time βž” Fact Measure Aggregation Rules.
  • Shared dimensions come from all sources βž” unions ListedDate, AuctionDate and SoldDate; unions Postcode, Suburb, City, State from all three PROPERTY tables, with select distinct wrapping the union to dedupe.

βš™οΈ Core Implementation

πŸ”Ή Vertical β€” one star per source, then one union

πŸ”Ή Horizontal β€” zero-pad every measure, union, then sum

πŸ”Ή Dimensions spanning all sources

βš–οΈ Core Decision Matrix

MethodTrigger conditionSQL shapeFailure mode if misapplied
Vertical Stackingevery source produces the same dimensions and the same measuresunion of the per-source facts; a source-identifying dimension (ClubID) distinguishes the rowsnone needed β€” but omitting the source key makes the stacked rows indistinguishable
Horizontal Stackingeach source owns different measures over shared dimensionsevery TempFact projects all measures, padding non-owned ones with 0; union then outer group by sumdropping the padding breaks union compatibility; dropping the outer sum leaves fragmented rows

When It Flips: the test is whether a source contributes new rows or new columns to the integrated fact β€” rows βž” vertical, columns βž” horizontal.

⚠️ Common Mistakes

  • πŸ’‘ Unioning raw source tables instead of per-source facts βž” the sources are structurally different; integration happens after each has been reduced to the agreed dimensions and measures.
  • πŸ’‘ Letting each club keep its own income formula into the fact βž” the measures must be reconciled to one definition first, or the stacked fact adds incomparable numbers.
  • πŸ’‘ Padding with null instead of 0 βž” sum ignores nulls in Oracle but the union’s type inference and any later arithmetic will not; the chapter pads with 0 throughout.
  • πŸ’‘ Forgetting that a source may hold an attribute the others lack βž” only the Inspection DB stores ListedDate, so NumNewListing can be sourced from nowhere else.

🧠 Active Recall