Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Database - fact table and dimension table

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.

like image 633
Jack_of_All_Trades Avatar asked Feb 20 '12 14:02

Jack_of_All_Trades


People also ask

What is the difference between dimension table and fact table?

A fact table holds the data to be analyzed, and a dimension table stores data about the ways in which the data in the fact table can be analyzed.

What is a dimension table in a database?

A dimension table is a table in a star schema of a data warehouse. A dimension table stores attributes, or dimensions, that describe the objects in a fact table. In data warehousing, a dimension is a collection of reference information about a measurable event.

Can a table be both fact and dimension?

Additionally, any table in a dimensional database that has a composite key must be a fact table. This means that every table in a dimensional database that expresses a many-to-many relationship is a fact table. Therefore a dimension table can also be a fact table for a separate star schema.


2 Answers

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", ...

like image 112
dani herrera Avatar answered Oct 29 '22 22:10

dani herrera


That's a standard in a datawarehouse to have fact tables and dimension tables. A fact table contains the data that you are measuring, for instance what you are summing. A dimension table is a table containing data that you don't want to constantly repeat in the fact table, for example, product data, statuses, customers etc. They are related by keys: in a star schema, each row in the fact table contains a the key of a row in the dimension table.

like image 20
stevie_c Avatar answered Oct 29 '22 21:10

stevie_c