DW 三个例子,让你看懂数据仓库多维数据模型的设计

710

一、概述

  多维数据模型是最流行的数据仓库的数据模型,多维数据模型最典型的数据模式包括星型模式、雪花模式和事实星座模式,本文以实例方式展示三者的模式和区别。

二、星型模式(star schema)

  星型模式的核心是一个大的中心表(事实表),一组小的附属表(维表)。星型模式示例如下所示:

In a star schema, a dimension does not have a subtable (a subdimension)

The benefit of having a star schema is that it is simpler than snowflake and galaxy schemas, making it easier for the ETL processes to load the data into DDS.

 

 

三、雪花模式(snowflake schema)

  雪花模式是星型模式的扩展,其中某些维表被规范化,进一步分解到附加表(维表)中。雪花模式示例如下图所示:

In a snowflake schema, a dimension can have a subdimension. The purpose of having a subdimension is to minimize redundant data.

The benefit of a snowflake schema is that some analytics applications work better with a snowflake schema compared to a star schema or galaxy schema. The other benefit of a
snowflake schema is less data redundancy, so less disk space is required. 

从图中我们可以看到地址表被进一步细分出了城市(city)维。supplier_type表被进一步细分出来supplier维。

 

四、事实星座模式(Fact Constellation)或星系模式(galaxy schema)

  数据仓库由多个主题构成,包含多个事实表,而维表是公共的,可以共享,这种模式可以看做星型模式的汇集,因而称作星系模式或者事实星座模式。本模式示例如下图所示:

The benefit of galaxy schema is the ability to model the business events more accurately by using several fact tables.

 

如上图所示,事实星座模式包含两个事实表:sales和shipping,二者共享维表。

五、总结

  事实星座模式是数据仓库最长使用的数据模式,尤其是企业级数据仓库(EDW)。这也是数据仓库区别于数据集市的一个典型的特征,从根本上而言,数据仓库数据模型的模式更多是为了避免冗余和数据复用,套用现成的模式,是设计数据仓库最合理的选择。当然大数据技术体系下,数据仓库数据模型的设计,还是一个盲点,探索中。


710
  1. 热门面试题

  1. 小编推荐