SpinTheMic
Pro

Data modeling · Beginner

What is the difference between a fact table and a dimension table?

By Anurag Pandey, Lead Data Engineer ·

The short answer

A fact table stores measurements from a business process, such as sales amounts, with foreign keys to dimensions. A dimension table stores the descriptive context, the who, what, where and when, that you filter and group by.

Practice this out loud

Opens this question on SpinTheMic. Start without signing up; sign in free for an AI report card.

Say it like this

About 50 seconds out loud. Use it as a model, then put it in your own words.

A fact table records events or measurements from a business process. In a sales model, each row is a sale, with numbers like quantity and amount, and foreign keys to the dimensions. Fact tables are usually long and narrow, and they grow fast. Dimension tables hold the context that describes those facts: the customer, the product, the store, the date. They're wider, with descriptive text columns, and much smaller. In a query, I filter and group by dimension attributes, like sales by product category by month, and I aggregate the measures from the fact table. There are a few kinds of fact table: transaction facts, one row per event; periodic snapshots, like account balance per day; and accumulating snapshots, which track a process like an order moving through its stages.

What interviewers look for

  • You explain facts as measurements and dimensions as descriptive context.
  • You use one consistent example, like sales.
  • You know there are different types of fact tables.

Common mistakes

  • Saying dimensions contain no numbers. They can, like a product's list price.
  • Putting descriptive text, like customer names, in the fact table.
  • Not knowing how facts and dimensions join, through surrogate keys.

Follow-up questions to expect

  1. 1What is a factless fact table?
  2. 2What are additive and semi-additive measures?
  3. 3Why use surrogate keys instead of natural keys?
Practice this out loud

Opens this question on SpinTheMic. Start without signing up; sign in free for an AI report card.

Checked against

All interview question guides