Skip to content

Junk dimension

A single dimension table that combines several unrelated flags and indicators, each with only a few possible values, into one row per combination. The fact table stores one key to it instead of a column or a tiny dimension for every flag.

Also: junk dimensions · transaction profile dimension

On this page · 7 sections
  1. Definition
  2. Example
  3. Why it matters
  4. Common mistakes
  5. FAQ
  6. Go deeper
  7. Related terms

A junk dimension collects the leftover flags of a business process into one table. Order systems produce plenty of them: payment method, order channel, a gift indicator, a rush indicator. Each has only a handful of distinct values (low cardinality), and none relates to the others. Modeled one by one, they would become four small dimensions and four more foreign keys on every fact row.

Combining them gives a table with one row per combination and a single key. Ralph Kimball's guidance is that the table does not have to hold every possible combination, only the ones that occur in the source data. In a schema diagram it is often given a more descriptive label, such as a transaction profile dimension.

The attributes should be stored as readable text. A gift column holding Gift and Not a gift filters and labels a report directly, where Y and N need a legend. New combinations appear over time, so the load checks each batch of fact rows for combinations it has not seen and adds a row for each before assigning keys.

create table dim_order_profiles as
select
  row_number() over (
    order by payment_method, order_channel, gift_status
  ) as order_profile_key,
  payment_method,
  order_channel,
  gift_status
from (
  select distinct payment_method, order_channel, gift_status
  from stg_orders
) as combos;

select
  o.order_id,
  p.order_profile_key,
  o.order_amount
from stg_orders o
join dim_order_profiles p
  on p.payment_method = o.payment_method
 and p.order_channel = o.order_channel
 and p.gift_status = o.gift_status
order by o.order_id;
Build the dimension from the combinations that occur, then look up one key per order for the fact table. The eight sample orders produce five profile rows; a cross join of the three payment methods, two channels, and two gift values would produce twelve.
Why it matters

It keeps the fact table narrow. One integer key replaces several columns on the largest table in the model, and the list of dimensions an analyst has to scan stays short.

It also keeps flags out of two worse places: loose text columns on the fact table, where they are repeated on every row, and a dimension they have nothing to do with, such as the customer table.

Common mistakes
  • Putting high-cardinality or related attributes into it. A junk dimension is for small, unrelated value sets. A column with thousands of values multiplies the row count, and attributes that describe the same thing belong in their own dimension.
  • Generating the full cross join of every flag when the possible combinations far outnumber the ones that ever occur.
  • Leaving the values as codes such as Y, N, 1, and 2, so every report needs a lookup to explain them.
FAQ
Why is it called a junk dimension?
Because it holds the miscellaneous attributes left over after the main dimensions are designed, in the way a junk drawer holds things that have no other place. The name describes how the attributes were grouped, not what they are worth. Payment method or order channel may be filtered on in every report.
What is the difference between a junk dimension and a degenerate dimension?
A junk dimension is a real table: several low-cardinality flags combined, joined to the fact table through one key. A degenerate dimension has no table at all. It is a single identifier, such as an order number, stored directly in the fact table because it has no attributes of its own. One groups flags; the other keeps a transaction number.
How many attributes should a junk dimension have?
There is no fixed number. What matters is the row count: the table needs one row per combination that occurs, so a few flags with a few values each stay small. If the number of combinations approaches the number of fact rows, the attributes are too varied to share a table and should be split up or modeled separately.