Keys to join the fact table with the dimension tables
Each dimensional table needs to include a primary key that corresponds to a foreign key in the fact table. The fact table should have a primary (composite) key that is a combination of the foreign keys.
![The "Sales Fact table" is in the center of the diagram. Lines illustrate the joins from the fact table to the four dimension tables: product, time, geography, customer. The reminder of the diagram is described in the surrounding text.](ddi042.gif)
- Sales fact table
- Product dimension table
- Time dimension table
- Customer dimension table
- Geography dimension table
Each of the dimensional tables includes a primary key (product, time_code, customer, district_code), and the corresponding columns in the fact table are foreign keys. The fact table also has a primary (composite) key that is a combination of these four foreign keys. As a rule, each foreign key of the fact table must have its counterpart in a dimension table.