Skip to content
PHP2Shell: The PHP Bug
Akshay Thakare

Star Schema Basics: Facts, Dimensions and Grain

Design analytics tables that answer business questions quickly and correctly — starting from the grain.

Data ModelingBeginner3 min readUpdated 11 Oct 2026

Start with the grain

The grain is one sentence: what does one row of this fact table represent? Everything else follows from it.

One row in fact_sales = one order line.

Facts and dimensions

Entity relationship diagramSwipe to explore →

Rendering entity relationship diagram

Fact tableDimension table
HoldsMeasurements (quantity, revenue)Descriptions (name, category, city)
RowsMany — one per event at the grainFewer — one per entity (or version)
KeysForeign keys to dimensionsSurrogate primary key
ChangesAppended / correctedUpdated (Type 1) or versioned (Type 2)

Design in four steps

  1. 1

    Pick the business process

    Orders, payments, shipments — one process per fact table.
  2. 2

    Declare the grain

    One sentence. If two measures have different grains, they belong in different facts.
  3. 3

    Choose the dimensions

    Who, what, where, when — anything you filter or group by.
  4. 4

    Add the facts

    Numeric measures that are true at that grain. Prefer additive measures (revenue) over ratios (margin %).

Finished this note?

Share