0

My understanding is that a fact table uses keys, which are dimensions that ought to have their own dimension table, to identify observations and assign them values. Can these values themselves be dimensions? Or does that violate some principle of a star schema?

For example, is this a valid fact table design?

Start Time Stop Time Employee ID Performance
01 60 0100 Grade 3
01 20 0200 Grade 2
20 60 0200 Grade 3

My dimensions that I use to identify facts are the first three columns, with the final column being an observation. However, if I have more information about what each Performance means, does that mean that there needs to be a Performance dimension table? Or, because Performance is an observation rather than a dimension, does this data need to be in the fact table itself?

J. Mini
  • 1,868
  • 1
  • 9
  • 38

1 Answers1

0

In a fact table there are normally 3 types of column:

  • measures: anything that can be aggregated
  • dimension keys: key to a record in a dimension table
  • degenerate dimensions: attributes that do not naturally sit in a dimension (often because they would be the only attribute in the dimension)

It is also possible for an attribute to be both a measure in a fact table and an attribute in a dimension. For example, the price of a product could be both a measure in a fact table and an attribute in the product dimension

Does this help?

Update

Say you wanted to know the average price of the products you have sold: in this case product price is a measure and lives in a sales fact table; that fact table would almost certainly have an FK to your Product Dimension - so you could filter on product attributes e.g. average price of product for products whose category = "Food".

You might also want to filter a query based on product price: in this case product price is an attribute in your product dimension (which would probably be an SCD2 dimension to cater for price changes). For example, you might want to query your stock-level fact table (which doesn't hold product prices as measures but does have an FK to the product dimension) for all products whose price is between £10 and £20

NickW
  • 8,430
  • 2
  • 6
  • 19
  • Can you elaborate more on that last point? In my mind, if the attribute is in the product dimension table, then the fact table should contain a column that is a foreign key for said table. – J. Mini Aug 11 '22 at 15:29