【问题标题】:Is a star schema a denormalized schema?星型模式是非规范化模式吗?
【发布时间】:2023-04-01 02:30:01
【问题描述】:

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

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

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

【问题讨论】:

    标签: schema olap star-schema oltp


    【解决方案1】:

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

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

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

    【讨论】:

    • @FrankPI 如果我有一个标准化的层次结构,如 Survey、Question、SubQuestion、AnswerChoices - 你会说带列的 1 维表:SurveyID、QuestionID、SubQuestionID、AnswerChoiceID、...[调查属性、问题、子问题和 AnswerChoices?这与 DimSurvey、DimQuestion、DimSubQuestion 等表相反...?
    • @jmsmcfrlnd 这取决于您要如何查询它,即。 e.运行的查询是什么?可能这还取决于您要使用的工具及其查询功能。
    • @FrankPI 使用此数据的工具是 Cognos,它使用框架为查询构建逻辑数据模型。我们将查询/分析调查问题的答案(在事实表中) - 但分析调查本身(例如,哪些问题比另一个问题表现“更好”,等等。
    • @FrankPI - 更正上述评论:我们将自行分析调查。 (由于某种原因无法编辑我的评论)
    • @jmsmcfrlnd 也许通过 cmets 进行对话不是讨论这个问题的好方法。把你的问题本身变成一个问题怎么样?包含以下信息也很好:您正在分析什么?同一个问题有不同类型的答案?会采取什么措施?
    【解决方案2】:
    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).
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-01
      • 2016-05-30
      • 2016-12-14
      • 1970-01-01
      • 1970-01-01
      • 2010-09-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多