Database - fact table and dimension table

Jack_of_All_Trades picture Jack_of_All_Trades · Feb 20, 2012 · Viewed 24.7k times · Source

When reading a book for business objects, I came across the term- fact table and dimension table. Is this the standard thing for all the database that they all have fact table and dimension table or is it just for business object design? I am looking for an explanation which differentiates between two and how they are related.

Edited:

Why cannot a query just get the required data from the fact table? What happens if all the information are stored in one fact table alone? What advantages we get by creating a separate fact and dimension table and joining it?

Sorry for too many questions at a time but I would like to know about the inter-relations and whys.

Answer

dani herrera picture dani herrera · Feb 20, 2012

Dimension and Fact are key terms in OLAP database design.

  • Fact table contains data that can be aggregate.
  • Measures are aggregated data expressions (e. Sum of costs, Count of calls, ...)
  • Dimension contains data that is use to generate groups and filters.
  • Fact table without dimension data is useless. A sample: "the sum of orders is 1M" is not information but "the sum of orders from 2005 to 2009" it is.

They are a lot of BI tools that work with these concepts (e.g. Microsft SSAS, Tableau Software) and languages (e. MDX).

Some times is not easy to know if a data is a measure or a dimension. For example, we are analyzing revenue, both scenarios are possibles:

  • 3 measures: net profit , overheads , interest
  • 1 measure: profit and 1 dimension: profit type (with 3 elements: net, overhead, interest )

The BI analyst is who determines what is the best design for each solution.

EDITED due to the question also being edited:

An OLAP solution usually has a semantic layer. This layer provides to the OLAP tool information about: which elements are fact data, which elements are dimension data and the table relationships. Unlike OLTP systems, it is not required that an OLAP database is properly normalized. For this reason, you can take dimension data from several tables including fact tables. A dimension that takes data from a fact table is named Fact Dimension or Degenerate dimension.

They are a lot of concepts that you should keep in mind when designing OLAP databases: "STAR Schema", "SNOWFLAKE Schema", "Surrogate keys", "parent-child hierarchies", ...