~/ learn/ comp-378/ cards/ The Star Schema: Facts, Dimensions, Grain & Surrogate Keys
1 of 10

Type the fact table at the heart of the star — measures + one FK per dimension, composite PK.

Type the fact table at the heart of the star — measures + one FK per dimension, composite PK.

Answer

CREATE TABLE sales_fact ( date_key int REFERENCES dim_date, product_key int REFERENCES dim_product, store_key int REFERENCES dim_store, customer_key int REFERENCES dim_customer, units int, revenue numeric(10,2), PRIMARY KEY (date_key, product_key, store_key, customer_key) );

The fact table carries the numeric measures (units, revenue) and one foreign key to each dimension. Its primary key is the COMPOSITE of all those foreign keys — and that composite is exactly the grain: one row per (date, product, store, customer).

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/a0ac3490-1cb0-496f-9e0c-9bdb00816088/flashcard utf-8 LF