Tuesday, September 16, 2008
How many facts?
Sunday, September 14, 2008
sk, the link of fact to dimension
SELECT order_number, sales_amount, order_quantity
FROM sales_fact sf, order_dim od, customer_dim cd, product_dim pd, date_dim dd
WHERE
sf.order_sk = od.order_sk
AND sf.customer_sk = cd.customer_sk
AND sf.product_sk = pd.product_sk
AND sf.date_sk = dd.date_sk
Friday, September 12, 2008
sk and the source keys
Wednesday, September 10, 2008
dimensions connect to fact and nothing else
Tuesday, September 9, 2008
sk for surrogate key
Every fact table that uses a dimension have the dimension's surrogate key; the surrogate keys link the fact to the dimension.
Thursday, September 4, 2008
Same grain of facts
For your reference I'm showing the DDL of the table here:
CREATE TABLE sales_fact (order_sk INT, customer_sk INT, product_sk INT, date_sk INT, sales_amount DEC(10,2), order_quantity INT);
The sales_amount fact is the total dollar amount of daily sales of each order, each customer, and each product, which is the grain of the fact. The other fact, the order_quantity, in the table must have the same grain.
Wednesday, September 3, 2008
Examples of Star Schema
CREATE TABLE sales_fact (order_sk INT, customer_sk INT, product_sk INT, date_sk INT, sales_amount DEC(10,2), order_quantity INT);
CREATE TABLE order_dim (order_sk INT, order_num INT);
CREATE TABLE customer_dim (customer_sk INT, customer_name CHAR(50));
CREATE TABLE product_dim (product_sk INT, product_code INT, product_name CHAR(50));
CREATE TABLE date_dim (date_sk INT, date DATE);
We can add another fact table (production_fact), which makes our schema a two-star schema:
CREATE TABLE production_fact (product_sk INT, factory_sk INT, date_sk INT, production_quantity INT);
CREATE TABLE factory_dim (factory_sk INT, factory_code INT, factory_name CHAR(50));
Note that this 2nd star (its production_fact table) shares the product_dim and date_dim tables from the 1st schema.
Tuesday, September 2, 2008
Star Schema
Your schema can have multiple stars, one for each of your fact tables.
Note that a dimensional table might be related (shared) to more than one fact table.
Wednesday, August 27, 2008
Two types of tables
Dimensional data warehouse has two types of tables (I’m talking about relational database tables here). The so-called fact table contains fact data, which is WHAT you want to analyze (fact is a.k.a. measure). Fact is numeric. Any measurement can be a fact, e.g. sales amount, count (of anything), percentage (of change), duration (elapsed time), score (soccer match result), grade (as in school), and rank (as in competition).