Data Modeling & Relationships in BI Tools
Define star-schema relationships, cardinality, and filter directions in BI models.
In plain words
A model says how your tables connect, such as each sale pointing to one product and one date, so charts can group the numbers correctly.
Think of it like…
A hub with spokes: the fact table is the ledger of transactions, each dimension is a lookup card, and a relationship is the rule that says "this transaction's product code points to exactly one product card". If two cards share a code, the ledger line gets counted twice.
Where you’ve seen it
A Sales fact table has rows (P1, $100) and (P2, $50), so true revenue is $150. A Product dimension accidentally contains two rows for key P1 ("Widget" and a renamed "Widget v2"). Because the key is no longer unique, Power BI cannot create a clean one-to-many relationship, and if the data is joined in SQL instead, the P1 sale appears twice: 100 × 2 + 50 = $250, an overstatement of 67%. The fix is to deduplicate the dimension to one row per product key (using a surrogate key and a type-2 history column if history matters), mark the date table, set the relationships Product[ProductKey] 1:* Sales[ProductKey] and Date[Date] 1:* Sales[OrderDate] with single-direction filtering, and add an inactive relationship to Sales[ShipDate] for the role-playing date.
Words you’ll hear
- Star schema
- One central fact table surrounded by denormalised dimension tables.
- Cardinality
- How rows correspond: one-to-many, many-to-one, one-to-one or many-to-many.
- Cross-filter direction
- Whether filters propagate one way (dimension to fact) or both ways.
- Role-playing dimension
- One dimension (date) used for several facts or fields such as order date and ship date.
Visual diagram
Theory & deep dive
Star schema, keys and cardinality
Model each business process as a fact table at a declared grain (one row per order line, per daily session) containing numeric measures and foreign keys, and surround it with dimensions that hold descriptive attributes (category, region, segment) used for slicing. Keep dimensions denormalised and flat (a snowflake adds joins without much benefit in a BI tool), use surrogate integer keys (stable and compact) and ensure the key on the "one" side is unique and non-null. Hide foreign keys and technical columns from report authors, and avoid a single wide flat table: it duplicates attributes, bloats memory and makes measures ambiguous.
Relationship cardinality is normally one-to-many from dimension to fact. One-to-one usually means the tables should be merged. Many-to-many relationships (for example facts linked to customers through a bridge, or two facts at different grains) need care: resolve them with a bridge table, or a shared dimension that both facts relate to (conformed dimension), instead of relying on a direct many-to-many relationship. Check data quality: orphan fact keys (no matching dimension row) appear as a blank member, and duplicate dimension keys break uniqueness or double count.
Sales: (P1, 100), (P2, 50) = 150. Dimension has two rows for P1. Joining multiplies the P1 sale: (P1, 100) twice + (P2, 50) = 250. A correct model requires one row per ProductKey, so each sale matches exactly one product.
Filter direction, role-playing dates and modelling traps
Cross-filter direction controls how filters travel. Single direction (dimension to fact) is the default and the safest: selecting a Product category filters Sales. Bidirectional filtering lets a fact filter a dimension (for example showing only customers who bought) but can create ambiguous paths, slow queries and unexpected results; prefer a measure (COUNTROWS of related facts greater than zero) or a visual-level filter, and enable bidirectional only deliberately, ideally for a bridge table. When two paths connect the same tables, the tool deactivates one, so check for ambiguity and use a single clear path.
A date dimension is essential: one row per day with year, quarter, month, week and fiscal fields, marked as the date table so time-intelligence functions (year-to-date, same period last year) work. A fact with several dates (OrderDate, ShipDate) uses a role-playing date: one active relationship (usually OrderDate) and inactive ones activated per measure with CALCULATE([Total Sales], USERELATIONSHIP(Sales[ShipDate], 'Date'[Date])), or separate date tables per role. In Tableau, relationships in the logical layer join tables at query time while preserving each table's grain, avoiding the fan-out of physical joins; define them on unique keys. Document grain, keys and relationship rules so the next analyst doesn't "fix" them.
Orders per day by order date uses the active relationship. A second measure, Shipped Sales = CALCULATE([Total Sales], USERELATIONSHIP(Sales[ShipDate], 'Date'[Date])), activates the inactive ship-date relationship for that measure only, so one Date table serves both questions.
How it works, step by step
Step 1 of 41. Declare the grain
Decide what one fact row represents and list the measures and foreign keys.
- Document
- the grain
When to use it & trade-offs
What it is
A BI data model defines how tables relate so that filters and aggregations behave correctly. The recommended shape is a star schema: a central fact table of events or measurements (sales lines, sessions) with foreign keys to surrounding dimension tables (date, product, customer, store). Relationships are defined by cardinality (usually one dimension row to many fact rows, written 1:*) and cross-filter direction (filters flow from the "one" side to the "many" side). Get these right and measures slice correctly by any dimension; get them wrong and totals double count, slicers do nothing or the model returns ambiguous results.
Why it matters: Most wrong dashboard numbers come from the model, not the visuals: duplicate keys that fan out joins, many-to-many relationships left unresolved, bidirectional filters that create ambiguity, or a missing date table that breaks time intelligence. Data scientists who feed BI tools with a clean star schema (and the dimension attributes analysts will slice by) get fast, trustworthy reports and avoid debugging numbers that look plausible but are wrong.
When to reach for it
- Any dashboard that slices measures by several attributes
- Models with multiple fact tables sharing dimensions
- Time intelligence across several date fields
When to avoid or be careful
- Duplicate keys on the dimension side
- Direct many-to-many relationships without a bridge
- Bidirectional filtering everywhere to make a slicer work
Modelling options
Strengths: Fast, clear filter flow, easy for authors.
Watch out: Needs upfront modelling and ETL.
Strengths: Quick to create.
Watch out: Redundant data, ambiguous measures, large memory.
Strengths: Less redundancy.
Watch out: More relationships and slower, harder models.
Interview signals & numbers to know
When this topic comes up
- “Totals are higher than the source”
- “The slicer doesn't filter that table”
- “Ambiguous relationship path”
- Fact and dimension tables
- Role-playing dates
Benchmarks & rules of thumb
- 1:*
- dimension-to-fact cardinality in a star schema
- $150 → $250
- overstatement from a duplicated product key
- 1 active
- relationship allowed between two tables at a time
Common mistakes & follow-ups
Common interview mistakes
- Loading the raw operational tables and hoping measures sort it out.
- Turning on bidirectional filters to fix a slicer and creating ambiguity.
- Skipping the date table and losing time-intelligence functions.
Likely interviewer follow-ups
- Why is a star schema preferred in BI tools?
- How do you handle two date columns on one fact table?
- What causes double counting in a model?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Data Modeling & Relationships in BI Tools with data science interview Q&A and hands-on practice.