Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
QA interview question
Databases, SQL & BIData / ETL / BIMiddleCommonTheory

How do fact tables, dimension tables and grain work in a star schema?

Answer

A fact table stores measurable events at a declared grain, while dimension tables provide descriptive context such as customer, product or date. Tests must prove that every fact row represents exactly one event at that grain and that dimension relationships do not duplicate or drop measures. Reconcile counts and totals from source to model, cover unknown and late-arriving dimensions, effective dates, slowly changing attributes and filter behaviour across every relationship.

Strong answer includes

  • defines fact, dimension and grain
  • detects duplicate amplification and missing relationships
  • reconciles measures and slowly changing attributes

Practical example

Aggregate facts through dimensions at a declared grain
Dialect · Portable SQLRuntime · static example

Requires the warehouse fact/dimension schema used by the example.

SELECT
  d.calendar_date,
  p.category,
  SUM(f.sales_amount) AS revenue
FROM fact_sales f
JOIN dim_date d    ON d.date_key = f.date_key
JOIN dim_product p ON p.product_key = f.product_key
GROUP BY d.calendar_date, p.category
ORDER BY d.calendar_date, p.category;

The fact table supplies measures and foreign keys; dimensions supply descriptive attributes. QA should verify that each join preserves the intended fact grain and does not duplicate sales rows.

Expected result: One aggregate row per date/category without duplicated fact measures.

#database#sql#star-schema#bi

Sources

Understand star schema and its importance for Power BIMicrosoft · Facts, dimensions, grain, relationships and semantic-model qualityPostgreSQL documentationPostgreSQL Global Development Group · Relational modelling, SQL, joins, constraints, transactions, concurrency, indexes, query plans and recovery