Fact Table vs. Dimension Table: What’s the Difference?

A fact table contains the primary keys to a referenced dimension table, and the dimension table contains the descriptive information. They make up the key components in star schema.

Published on Feb. 21, 2024
Fact Table vs. Dimension Table: What’s the Difference?
Image: Shutterstock / Built In
Brand Studio Logo

As organizations generate and consume an increasing volume of data, effective data management is becoming more challenging, particularly when it comes to data storage and modeling. Therefore, establishing a proper data structure is critical for managing data effectively.

Fact Table vs. Dimension Table Defined

  • Fact table: A fact table contains the primary keys of the referenced dimension tables along with some quantitative metrics. Examples of a fact table include customer orders or time-series financial data.
  • Dimension table: A dimension table holds the descriptive information for the related fields that are in the fact table’s records. It typically represents a physical entity like “customer” or “product.” 

In this article, we’ll explore a widely-used principle in data engineering known as star schema, and delve into its two primary components: Fact and dimension tables. A fact table holds primary keys of the referenced dimension tables along with quantitative metrics. A dimension table holds the descriptive information for all fields included in a fact table.

We’ll discuss their differences in further detail and provide an end-to-end example to demonstrate how these concepts are utilized in real-world projects.


Fact Table vs. Dimension Table in Star Schema

Star schema is widely used for modeling data warehouses and dimensional data marts. It’s composed of a single fact table that references any number of dimension tables.

This schema is a variant of the Snowflake schema and is typically used to enable simpler query sets. The name “star schema” originates from the fact table’s central position in the schema diagram, surrounded by dimension tables.

More on Data Science4 Ways Unstructured Data Management Will Change in 2024


Fact Table vs. Dimension Table Explained

A fact table is one that holds the primary keys of the referenced dimension tables along with some quantitative metrics, i.e. measurements, over which a calculation can be performed. Some common examples of facts tables include orders, logs and time-series financial data.

Dimension tables hold the descriptive information for all related fields that are included in the fact table’s records. A few common examples of dimension tables are physical entities such as “Customer” and “Product” tables or even “Time” tables. In general, dimension tables are expected to be much smaller in size in comparison to fact tables.


How to Differentiate a Fact Table vs. Dimension Table

A straightforward approach to differentiating fact tables from dimension tables is to examine whether a table refers to a noun, such as a physical object or person. For instance, a product or a customer may exist independently of any specific business event. Dimension tables, therefore, represent nouns since they represent something that either takes action or has action taken upon it, such as a physical store, customer or product.

On the other hand, a verb usually corresponds to a fact table. Each record corresponds to an event in which entries from dimension tables are involved. For example, an order involves a customer and a product (or potentially more). The act of placing an order is made by a specific customer for a specific product.

As an example, let’s consider a use-case where customers purchase products in physical stores. The star schema is illustrated below.

Example of fact and dimension tables in star schema
Example star schema with a fact table in orange and dimension tables in blue. | Image: Giorgos Myrianthous

Dimension tables, which are in blue, correspond to the tables containing information about the “Customers,” “Stores,” “Products” and “Dates.” These are the nouns of the business case.

The fact table shown in orange, contains all the primary keys (PK) of the dimension tables, which are the foreign keys (FK) in the fact table, along with two quantitative fields, namely quantity and amount.

A fact table could exist without a primary key, but usually, they are assigned a surrogate key.


Benefits of Fact Table and Dimension Table in Star Schema

Due to the denormalized nature of the model, star schema tends to be faster in terms of performance. At the same time, Star schema tends to be fairly simple, and thus, the overall structure is easier to be designed. Additionally, it’s much more readable, even if it’s not as maintainable as snowflake schema.

The structure of the star schema facilitates data aggregation, with a fact table typically joined to only one level of dimension tables. This simplicity reduces the complexity of queries for data engineers and scientists and may also simplify the testing process. Additionally, the efficient query performance of the star schema helps minimize the risk of adversely affecting other OLAP products.


Disadvantages of Fact Table and Dimension Table in Star Schema

As previously mentioned, dimensions in the star schema are denormalized, potentially leading to repeating values within a table. Consequently, storage requirements for star schema are relatively larger than those of other schemas, such as the normalized snowflake schema. If storage size is a concern, this data redundancy may warrant reconsideration of the star schema.

Furthermore, the data redundancy in the star schema heightens the risk to data integrity, as new updates, deletions, and insertions may affect the overall data integrity due to data being repeated in multiple records.

Although the star schema is simple to design and implement because of the straightforward relationships between tables, maintaining it may pose a challenge due to the aforementioned data integrity concerns. With new data ingested and potential creation of new tables, validating and preserving data integrity throughout the data warehouse may become difficult.

A tutorial on the differences between fact table vs. dimension table. | Video: Kishan Mashru

More on Data Science5 Steps for Painless Data Migration


Understanding Fact Table vs. Dimension Table

In this article, we highlighted the importance of having a proper structure for data storage to enable effective management of data. We discussed the star schema, a commonly used principle in data engineering, and its two main components, fact and dimension tables. 

In addition, we’ve seen how to apply these concepts in real use-cases. We also examined the pros and cons of the star schema, including its potential storage and data integrity issues.

Ultimately, the decision to use star schema depends on the specific circumstances, and alternative approaches such as the snowflake schema should be considered as necessary. By understanding star schema, data engineers and scientists can build efficient data storage structures and perform effective data analysis.

Hiring Now
Relativity Space
3D Printing • Aerospace • Hardware • Robotics • Software