Facts
A fact is a value that describes a specific event or activity. Facts are typically numeric and can be aggregated to provide insight into a dataset. For example, a sales dataset might include facts such as the total sales revenue, the number of units sold, or the average sales price.
Facts are associated with dimensions through the fact table, which contains the measurements (Measures) for each event or activity. The fact table typically contains foreign keys to link the fact table to the dimension tables.
Facts are the numerical data that we want to analyze. They are the values that we measure and aggregate in order to gain insights into our data. In a sales data warehouse, the facts could include sales revenue, quantity sold, and profit.
Each fact has a corresponding measure that defines the unit of measurement for the fact. For example, revenue could be measured in dollars, while quantity sold could be measured in units.
The fact table contains the numerical values, and it is linked to the dimension tables through foreign key relationships. The fact table is typically wide and has fewer rows than the dimension table.
Best practices for designing facts include the following:
• Choose appropriate measures: It is important to choose measures that are meaningful and appropriate for the business.
• Normalize the data: Normalizing the data in the fact table can help to reduce redundancy and improve performance.
• Use additive measures: Additive measures can be aggregated across all dimensions, while non-additive measures are specific to a single dimension.
Measures
Measures are the values that we use to aggregate and analyze the facts. Measures are the result of applying mathematical functions to the numerical data in the fact table.
For example, measures could include average sales, total sales, and maximum sales. Measures can be simple or complex, and they can be derived from one or more facts. Measures can be pre-calculated and stored in the fact table, or they can be calculated on the fly when the user queries the data warehouse.
Best practices for designing measures include the following:
• Choose appropriate functions: It is important to choose functions that are appropriate for the business and the data being analyzed.
• Use consistent units of measurement: Measures should use consistent units of measurement to avoid confusion.
• Avoid calculations in the query: Pre-calculate measures that are frequently used to improve performance.
The dimensional modeling technique provides a powerful method for designing data warehouses. The key concepts of dimensions, facts, and measures are essential to the design of a successful data warehouse. By following best practices for designing dimensions, facts, and measures, you can create a data warehouse that is easy to use, efficient, and provides meaningful insights into your data.