码迷,mamicode.com
首页 > 其他好文 > 详细

Factless Fact Table

时间:2015-04-15 15:08:47      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

A factless fact table is a fact table that does not have any measures. It is essentially an intersection of dimensions. On the surface, a factless fact table does not make sense, since a fact table is, after all, about facts. However, there are situations where having this kind of relationship makes sense in data warehousing.

For example, think about a record of student attendance in classes. In this case, the fact table would consist of 3 dimensions: the student dimension, the time dimension, and the class dimension. This factless fact table would look like the following:

技术分享

The only measure that you can possibly attach to each combination is "1" to show the presence of that particular combination. However, adding a fact that always shows 1 is redundant because we can simply use the COUNT function in SQL to answer the same questions.

Factless fact tables offer the most flexibility in data warehouse design. For example, one can easily answer the following questions with this factless fact table:

  • How many students attended a particular class on a particular day?

  • How many classes on average does a student attend on a given day?

Without using a factless fact table, we will need two separate fact tables to answer the above two questions. With the above factless fact table, it becomes the only fact table that‘s needed.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

以下内容转自 http://www.cnblogs.com/lijun4017/archive/2010/08/04/1792293.html

浅析非事实型事实表

在维度建模的数据仓库中,有一种事实表叫Factless Fact Table,中文一般翻译为“非事实型事实表”。在事实表中,通常会保存十个左右的维度外键和多个度量事实,度量事实是事实表的关键所在。在非事实型事实表中没有这些度量事实,只有多个维度外键。非事实型事实表通常用来跟踪一些事件或者说明某些活动的范围。下面举例来进行说明。

第一类非事实型事实表是用来跟踪事件的事实表。例如:学生注册事件,学校需要对学生按学期进行跟踪。维度表包括学期维度、课程维度、系维度、学生维度、注册专业维度和取得学分维度,而事实表是由这些维度的主键组成,事实只有注册数,并且恒为1。这样的事实表可以回答大量关于大学开课注册方面的问题,主要是回答各种情况下的注册数。

第二类非事实型事实表是用来说明某些活动范围的事实表。例如:促销范围事实表。通常销售事实表可以回答如促销商品的销售情况,但是对于那些没有销售出去的促销商品没法回答。这时,通过建立促销范围事实表,将商场需要促销的商品单独建立事实表保存。然后,通过这个促销范围事实表和销售事实表即可得出哪些促销商品没有销售出去。这样的促销范围事实表只是用来说明促销活动的范围,其中没有任何事实度量。

以下内容转自 http://www.cnblogs.com/lijun4017/archive/2010/08/04/1792440.html

我们用非事实型事实表来记录维度之间的多对多关系,但是关系上没有数字或者文本的事实。非事实型事实表一般用来记录事件或者范围信息。常见的例子如:标识产品的促销范围;记录学生出席或者注册事件等。

在本TIP中我们用非事实型事实表来补充缓慢变化维的处理策略。

对于一个大型的B2C企业来说,会有上千万的客户。对于这种大型的客户表,需要跟踪客户的变化情况,我们可以采用TYPE 2的缓慢变化维策略来进行应对。例如,一个大的客户表,我们尽量减小TYPE 2生成的记录数,建立了四个微型维度,分别是客户信用属性、客户参数、市场倾向和客户详细地址。这样在交易粒度事实表中我们会保留客户相关信息的五个外键,这些外键关联到客户不同的信息。

同时,我们还应该支持客户的整体信息的访问。为了能方便访问客户的整体信息,我们可以建立另一个周期快照事实表,每天加载客户维度和其相关联的微型维度的关系。但是这样就需要每天保存上千万记录的快照,不是一个好的选择。

这时,我们可以考虑建立非事实型事实表来解决这个问题。我们可以建立一个事实表,其中只有客户维度和其对应微型维度的外键,当客户有TYPE 2变化时或者产生新的微型维度记录时,我们可以在这个事实表中插入一条记录。在这个事实表中还可以加入生效日期和失效日期,可以加一列用来标识是当前客户信息记录,可以加变化原因列


Factless Fact Table

标签:

原文地址:http://my.oschina.net/duanfangwei/blog/401818

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!