0

I have designed a fact table that stores the facts for a specific date dimension and an action type such as create, update or cancelled. The facts can be create and cancelled only once, but update many times.

myfact
---------------
date_key
location_key
action_type_key

This will allow me to get a count for all the updates done, all the new ones created for a period and specify a specific region through the location dimension.

Now in addition I also have 2 counts for each fact, i.e. Number of People, Number of Buildings. There is no relation between these. And I would like to query on how many of the facts having a specific count, such as how many have 10 building, how many have 9 etc.

What would be the best table design for these. Basically I see the following options, but am open to hear better solutions.

  1. add the counts as reference info in the fact table as people_count and building_count

  2. add a dimension for each of these that stores the valid options, i.e. people dimension that stores a key and a count and building dimension that stores a key and a count. The main fact will have a people_key and a building_key

  3. add one dimension for the count these is used for both people and building counts, i.e. count dimension that stores a key and a generic count. The main fact will have a people_count_key and a building_count_key

4

1 回答 1

0

首先,您的计数本质上是最纯粹意义上的“维度”(您可以将维度视为对记录进行分组以进行报告的一种方式)。但问题是维度建模是否是您想要做的。我认为您最好将其视为隐含维度,而不是添加维度表。这本质上意味着维度表没有添加任何内容,并且它们会产生错误的极端情况,除非您需要跟踪与数字相关的一堆信息,否则我认为这不是很有帮助。

如果是我,我只会将计数添加到事实表,而不是其他表。

于 2013-03-26T06:47:38.030 回答