Difference between Fact table and Dimension table?

332,789

Solution 1

This is to answer the part:

I was trying to understand whether dimension tables can be fact table as well or not?

The short answer (INMO) is No.That is because the 2 types of tables are created for different reasons. However, from a database design perspective, a dimension table could have a parent table as the case with the fact table which always has a dimension table (or more) as a parent. Also, fact tables may be aggregated, whereas Dimension tables are not aggregated. Another reason is that fact tables are not supposed to be updated in place whereas Dimension tables could be updated in place in some cases.

More details:

Fact and dimension tables appear in a what is commonly known as a Star Schema. A primary purpose of star schema is to simplify a complex normalized set of tables and consolidate data (possibly from different systems) into one database structure that can be queried in a very efficient way.

On its simplest form, it contains a fact table (Example: StoreSales) and a one or more dimension tables. Each Dimension entry has 0,1 or more fact tables associated with it (Example of dimension tables: Geography, Item, Supplier, Customer, Time, etc.). It would be valid also for the dimension to have a parent, in which case the model is of type "Snow Flake". However, designers attempt to avoid this kind of design since it causes more joins that slow performance. In the example of StoreSales, The Geography dimension could be composed of the columns (GeoID, ContenentName, CountryName, StateProvName, CityName, StartDate, EndDate)

In a Snow Flakes model, you could have 2 normalized tables for Geo information, namely: Content Table, Country Table.

You can find plenty of examples on Star Schema. Also, check this out to see an alternative view on the star schema model Inmon vs. Kimball. Kimbal has a good forum you may also want to check out here: Kimball Forum.

Edit: To answer comment about examples for 4NF:

  • Example for a fact table violating 4NF:

Sales Fact (ID, BranchID, SalesPersonID, ItemID, Amount, TimeID)

  • Example for a fact table not violating 4NF:

AggregatedSales (BranchID, TotalAmount)

Here the relation is in 4NF

The last example is rather uncommon.

Solution 2

In Data Warehouse Modeling, a star schema and a snowflake schema consists of Fact and Dimension tables.

Fact Table:

  • It contains all the primary keys of the dimension and associated facts or measures(is a property on which calculations can be made) like quantity sold, amount sold and average sales.

Dimension Tables:

  • Dimension tables provides descriptive information for all the measurements recorded in fact table.
  • Dimensions are relatively very small as comparison of fact table.
  • Commonly used dimensions are people, products, place and time.

enter image description here

image source

Solution 3

This appears to be a very simple answer on how to differentiate between fact and dimension tables!

It may help to think of dimensions as things or objects. A thing such as a product can exist without ever being involved in a business event. A dimension is your noun. It is something that can exist independent of a business event, such as a sale. Products, employees, equipment, are all things that exist. A dimension either does something, or has something done to it.

Employees sell, customers buy. Employees and customers are examples of dimensions, they do.

Products are sold, they are also dimensions as they have something done to them.

Facts, are the verb. An entry in a fact table marks a discrete event that happens to something from the dimension table. A product sale would be recorded in a fact table. The event of the sale would be noted by what product was sold, which employee sold it, and which customer bought it. Product, Employee, and Customer are all dimensions that describe the event, the sale.

In addition fact tables also typically have some kind of quantitative data. The quantity sold, the price per item, total price, and so on.

Source: http://arcanecode.com/2007/07/23/dimensions-versus-facts-in-data-warehousing/

Solution 4

Super simple explanation:

Fact table: a data table that maps lookup IDs together. Is usually one of the main tables central to your application.

Dimension table: a lookup table used to store values (such as city names or states) that are repeated frequently in the fact table.

Solution 5

Dimension table Dimension table is a table which contain attributes of measurements stored in fact tables. This table consists of hierarchies, categories and logic that can be used to traverse in nodes.

Fact table contains the measurement of business processes, and it contains foreign keys for the dimension tables.

Example – If the business process is manufacturing of bricks

Average number of bricks produced by one person/machine – measure of the business process

Share:
332,789

Related videos on Youtube

Admin
Author by

Admin

Updated on April 14, 2022

Comments

  • Admin
    Admin about 2 years

    When reading a book for business objects, I came across the term- fact table and dimension table.

    I am trying to understand what is the different between Dimension table and Fact table?

    I read couple of articles on the internet but I was not able to understand clearly..

    Any simple example will help me to understand better?

    • NoChance
      NoChance over 10 years
      The concept is rather long to describe in good detail, if you have a specific problem beyond the basic definition please tell us about it.
    • Admin
      Admin over 10 years
      Basically, I was trying to understand whether dimension tables can be fact table as well or not?
    • Channa
      Channa about 4 years
  • NoChance
    NoChance over 10 years
    Some fact tables reflect transaction level data. Some reflect aggregated data. A fact table in a Star Schema does not have to be even in 3NF. For example Sales Fact could contain data such as (ID, BranchID, Amount, SalesPerson, Time) - This violates 3NF, BCNF and 4NF because the SalesPerson and Branch dependency.Accordingly, it is not true that a typical fact table is in 4NF.
  • Booji Boy
    Booji Boy over 6 years
    this is so much more helpful than the accepted answer
  • sɐunıɔןɐqɐp
    sɐunıɔןɐqɐp about 6 years
    (This post does not seem to provide a quality answer to the question. Please either edit your answer, or just post it as a comment to the question).
  • user1951
    user1951 over 5 years
    Great writing, only needed 5 mins to understand the concept.
  • youcantryreachingme
    youcantryreachingme over 5 years
    To summarise: dimensions are attributes of fact-events. DAFE. What are you doing, DAFE?
  • The One
    The One over 5 years
    Well, A picture is worth a thousand words. I didn't understand anything when reading the other answers, but this one saved me.
  • undrline - Reinstate Monica
    undrline - Reinstate Monica over 5 years
    Yes, that's how I remember them. It's the reverse of what you'd think. You'd think facts are set in stone and dimensions are dynamic, based on the words themselves. But, it's the opposite: a basic dim table is a fairly static lookup list, and a basic fact table is living data that's being entered.
  • Arjun Arun
    Arjun Arun over 4 years
    This was my favorite explanation and caused it to click in my head, thanks!
  • Blue Clouds
    Blue Clouds over 4 years
    Dimensions look relatively large as compared to fact table in the diagram as it has more descriptive data. And they are more in numbers too
  • Daniel
    Daniel over 4 years
    @Blue Clouds: You have to realize that the Fact-Table contains one entry for every possible combination of the for dim´s (if there is data, at least). While the Location Dimension will at max contain one entry for every possible location (say 50 points-of-sale) and will grow rarely, when new pos are added, the Facts table will probably grow for each day by location x items x branches. So, the facts will get large in number of records pretty fast.
  • Kalana
    Kalana about 4 years
    @Premraj Can fact table exist without primary key?
  • Manikandan Kbk DIP
    Manikandan Kbk DIP almost 4 years
    @Kalana, Yes a fact table can exists without a primary key. For example, a sales table with columns, cust_id, date_ordered, qty, time, location can have all records same if he/she ordered in the same day / same location / same qty twice.
  • BGT
    BGT over 2 years
    Good explanation of concept. Can you give some database scenarios where we use this Star schema(fact/dim tables).
  • Stormbringer
    Stormbringer over 2 years
    I have used "master data" and "transactional data" for years as well, and I think that they are linguistically more evident regarding what the words entail.
  • Admin
    Admin over 2 years
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
  • NYCeyes
    NYCeyes about 2 years
    This is a well-written answer.