A fact table is a table that stores fact where a fact can be seen as the representation of an event.
It's also known as:
In a dimensional modelling, this table is located at the centre of a star schema or a snowflake schema, surrounded by dimension tables.
They contains only transactions and are therefore only one time column. If this is not the case, this is an order table.
Transactions are often group in what is called an order. The cardinality between the order table and the transaction table is really low. There has on average a couple of transaction for one order. Due to the number of rows in this table, she is really often seen as a fact table but it's not. You may find an order attribute into the fact table for performance reason (see Dimensional Data Modeling - Degenerate Dimension of Fact dimension (i.e. event/header entity))
A fact table is the primary table in a dimensional model where the performance measurements of the events are stored.
One fact table = One business process Step = One Star Schema in a data mart
Fact tables express the many-to-many relationships between dimension in dimensional model.
Fact are determined by retrieving the temporal nature of the table:
In a reporting point of view, a fact table can only hold one date column. No analytic report will ask you to show more than one date). The time is universal and hold more than one event. The reports want to know what kind of event have taking place in one day.
A fact table in a Data Mart is composed :
The combination of all foreign keys (customer, store, …) and of the date column doesn't create a unique key. On the same second, you can have another transaction that concerns the same foreign keys.
Using Id columns for the foreign keys and for the date column permits:
A fact table is a table with measures (column where you will perform an aggregation sum, …). In a classic star schema any table that only has many-to-one (N:1) joins to it is a fact table.
In a schema, a table where all the joins have the many-to-one symbol (crow's feet, arrow, …) pointing into the table, and no joins pointing out of it, is, in essence, a fact table. One exception to this rule is a bridge table when you model a many-to-many relationship.
The grain is the level of detail and is defined by the combination of dimension.
A row in a fact table correspond to a event. An event is a row in a fact table. All events have the same grain.
In some cases, fact tables may contain no numerical facts at all. There are no measures involved. The important information is simply that the event took place or not.
The only relevant aggregation operation for such types of table is COUNT.
For example:
To answer this kind of question:
What product were on promotion but did not sell ?
One solution that found database designer is to create a factless fact table which contains all the related informations. This table can leverage a huge amount of data.
Fortunately, other solutions exist such as:
There are basically two forms of historical fact tables:
A transactional fact table is insert only and stores changes as the difference between the current state and the new state. Depending on what changes, it would require one or two new rows.
An accumulating snapshot stores each new version of the fact bound by effective and expiration dates. It requires updating the expiration date of the previous version of the fact.
Both will allow you to generate a set of facts at any point in time, the first by summing up to the desired date and the other by filtering facts within the effective range. A transactional fact has the advantage of being able to easily query the magnitude and direction of change.