Junk Dimensions

Context: FIT3003_MOC Β· what to do when a star sprouts several two-row dimensions βž” One-Attribute Dimensions, Building Dimension Tables Parent Framework: Star Schema

Quick Revision

  • 🎯 Objective: consolidate several low-cardinality, mutually unrelated dimensions into one dimension table βž” the junk dimension is the Cartesian product of their members, keyed by a single JunkID.
  • πŸ“¦ Core Components: βž” Real-Estate: rows.
  • ⚑ Key Constraint: low cardinality and unrelated are both required β€” a combined key (SemesterID year semester) or a hierarchy (city country) is not a junk dimension.

πŸ“ How It Works

1. The Real-Estate case

  • Source βž” one large Property table; four of its columns are yes/no or four-valued: Ensuite, Pool, Spa, Aspect_Facing (East/North/South/West).
  • Measures βž” Num_of_Property and Total_Price; the analysis question is β€œhow many properties have a pool and a spa”, β€œwhich face north”.
  • Option 1 β€” non-junk βž” four separate dimensions β€” five tables in the star.
  • Option 2 β€” junk βž” one dimension β€” two tables in the star, and the fact still holds rows.
  • Bound on size βž” the junk dimension’s row count is never more than the fact’s row count, because it is only the combinations that the fact can key on.

2. What is not a junk dimension

  • A combined key βž” SemYearDIM(SemesterID, Semester, Year) where is just year semester made unique; the alternative is to split it into SemesterDIM and YearDIM, not to call it junk.
  • A hierarchy βž” CampusDIM(CampusID, …, CityName, State, Postcode, Country) splits into a city country hierarchy (a snowflake) or into two independent dimensions β€” the attributes are related, so consolidating them is normal modelling.
  • The discriminator βž” junk needs many members, each cheap and no relationship between the attributes; both counter-examples fail the second test.

βš™οΈ Core Implementation

πŸ”Ή Option 1 β€” the non-junk build (four dimensions)

πŸ”Ή Option 2 β€” the junk build (one dimension, sequence-keyed)

βš–οΈ Core Decision Matrix

AspectNon-junk (one dimension per attribute)Junk (one consolidated dimension)
Tables in the star
Fact keycomposite of FKssingle JunkID
Simple filter queryPropertyFact1 PF, PoolDim P, SpaDim S β€” 3 tables, 2 join conditionsPropertyFact2 PF, JunkDim J β€” 2 tables, 1 join condition
Nested β€œfeatures of the dearest property”5 tables, 4 join conditionsselect * from the fact alone, or fact JunkDim for the labels
Adding an attribute latera new dimension and a new FK in the factrebuild JunkDim β€” every JunkID is renumbered
Readability of the factkeys are self-describingJunkID = 17 means nothing without the join

When It Flips: consolidate as soon as the attributes are unrelated and their cardinalities are small enough that stays comfortably below the fact's row count. If any one dimension is large, or two of them are related, the product explodes or the model lies β€” keep them separate.

🧠 Active Recall