Model studio
Draw a data model at three levels, change it, and generate the tables for PostgreSQL, Spark SQL with Delta Lake and T-SQL; then run the PostgreSQL version on the estate's data, in your browser.
Exercise: Make the extract a star
The board's report reads one wide table, with the product's and the customer's details copied onto every claim. Make it a star: the claim stays a fact with its reserve, and the product and the customer become dimensions it refers to.
- The fact keeps its measure.
- The product line lives in a dimension the fact refers to.
- The customer's name lives in a dimension the fact refers to.
- Every dimension is one hop from the fact: no dimension refers to another table.
- No description is left on the fact.
Logical: every attribute with its type and keys (PK, FK), independent of any database; a question mark marks an optional attribute.
Edit fact_claim
One row per claim, with every detail the report shows typed onto it.
The generated tables
Checked in CI on a real PostgreSQL 18.3, and run below in PGlite, the same release.
CREATE TABLE fact_claim (
claim_id integer GENERATED BY DEFAULT AS IDENTITY NOT NULL,
loss_date date NOT NULL,
product_line text NOT NULL,
product_name text,
customer_name text NOT NULL,
country char(3),
reserve numeric(12,2) NOT NULL,
CONSTRAINT pk_fact_claim PRIMARY KEY (claim_id)
);
COMMENT ON TABLE fact_claim IS 'One row per claim, with every detail the report shows typed onto it.';
COMMENT ON COLUMN fact_claim.claim_id IS 'Surrogate key';
Run it on the data
PostgreSQL starts in this browser when you press Run.
| Table | PGlite | Seed | Same |
|---|
Used in
- Chapter 5 · Conceptual models: the business in boxes
- Chapter 6 · Logical models
- Chapter 7 · Physical models: one logical model, four physical designs
- Chapter 8 · Canonical models for integration
- Chapter 27 · The medallion architecture 2: design choices
- Chapter 39 · Stage 2: Common meaning
Glossary: Conceptual modelLogical modelPhysical modelPrimary keyForeign key