11

OLAP 数据库由非规范化形式的数据组成。这意味着数据冗余,这种数据冗余有助于通过更少的连接来检索数据,从而促进更快的检索。

但是 OLAP 数据库的流行设计是事实维模型。事实表将存储基于事实的数字条目(销售额等),而维度表将存储与事实相关的“描述性属性”,即进行销售的客户的详细信息。

我的问题是,在这种设计中,它似乎根本没有非规范化,因为所有维度表都具有对事实表的外键引用。它与 OLTP 设计有何不同?

4

2 回答 2

10

非规范化在星型模式的维度表中:例如。在一个产品表中,您在这个表中明确地有许多列,例如产品类别的多个级别,而不是每个级别都有一个表,并使用引用这些值的外键。

这意味着您对事实进行了规范化,但停止对维度表进行规范化。

此外,您通常甚至没有将事实完全规范化。一个典型的例子是:在一个完全规范化的表中,您将只使用两列“售出的单位数”和“每单位的价格”,但在 OLAP 数据库中,冗余地为“提供另一列”可能是有意义的销售价值”,可以很容易地通过将销售的单位乘以每单位的价格来计算。

于 2013-08-26T11:46:12.510 回答
1
You can get the difference if you study first "highly normalized schemas".
https://www2.microstrategy.com/producthelp/10.6/ProjectDesignGuide/WebHelp/Lang_1033/Content/ProjectDesign/Highly_normalized_schema__Minimal_storage_space.htm

Will give you an example: Consider a "city" inside a "country" for a "person",
all what you need to store for a person is only his "city" because anyway that city resides in a "country". 
so you don't have also to store the "country" in the "person" table. 
This approach will have advantage of "minimal" storage. 
But as disadvantage it will be annoying to retrieve "country" for a "person"
 since you will have to do many joins to achieve that.

So regarding your question, in your design, if we stored both "city_id" and "country_code" in "person" table, 
this will cause little redundancy but as advantage it will be more easier to get "person" "country" by directly joining the two tables "Countries" and "person" together. 

Normalization main purpose is to remove redundancy. And to achieve data consistency. 
For example, in your case OLAP , developer can make mistake by inserting correct "city_id" and wrong "country_id" 
for example he can insert "Paris" as city and by mistake he can insert "Germany" as the country which is wrong.
If the schema is fully normalized, this cannot never happens since it will store only "Paris" "city id" in "party" table and will not store "country" id.

  So yes, OLAP is de-normalized since it allows data redundancy and developers (application) mistakes (if any).
于 2018-10-26T20:36:27.557 回答