top of page

FACT AND DIMENSION TABLE

  • Writer: Abhinandan Borse
    Abhinandan Borse
  • Sep 23, 2023
  • 2 min read

A fact table is a central table in a star schema or snowflake schema of a data warehouse. It contains quantitative data (facts) related to a business process or event, and is typically associated with dimension tables.

Here's an example of a fact table for an e-commerce business:

Fact Table: Sales



In this example:

  • order_id: A unique identifier for each order.

  • product_id: A foreign key linking to the product in the Products dimension table.

  • customer_id: A foreign key linking to the customer in the Customers dimension table.

  • order_date: The date when the order was placed.

  • quantity: The quantity of the product ordered.

  • total_price: The total price of the order.

This fact table allows for easy analysis of sales data. For instance, you can query the total sales revenue for a specific date range, analyze the best-selling products, or calculate average order value.

The fact table's primary keys are usually the combination of the foreign keys (e.g., order_id, product_id, customer_id) to ensure each row is uniquely identified.









A dimension table in a data warehouse is a table that contains descriptive attributes related to specific business processes or events. It provides context to the quantitative data stored in the fact table. Here's an example of a dimension table for products in an e-commerce business:

Dimension Table: Products






  • product_id: A unique identifier for each product.

  • product_name: The name or description of the product.

  • category: The category to which the product belongs (e.g., electronics, clothing).

  • price: The price of the product.

This dimension table provides additional information about each product, allowing for meaningful analysis when combined with the fact table. For instance, you can use this table to understand which products are in high demand, analyze sales by category, or calculate revenue by product.

The dimension table is typically smaller in size compared to the fact table, and it's linked to the fact table using foreign key relationships (e.g., product_id). This relationship enables the aggregation of data across dimensions for reporting and analysis.

Recent Posts

See All

コメント


Subscribe Form

Thanks for submitting!

  • Facebook
  • Twitter
  • LinkedIn

©2020 by Pythoneer. Proudly created with Wix.com

bottom of page