数据库——事实表和维度表
在阅读一本关于业务对象的书时,我遇到了术语——事实表和维度表。这是所有数据库的标准做法,它们都有事实表和维度表,还是只是为了业务对象设计?我正在寻找一种解释来区分两者以及它们之间的关系。
编辑:
为什么查询不能从事实表中获取所需的数据?如果所有信息都单独存储在一张事实表中会发生什么?通过创建单独的事实和维度表并将其连接起来,我们可以获得什么优势?
抱歉一次问太多问题,但我想了解其中的相互关系和原因。
When reading a book for business objects, I came across the term- fact table and dimension table. Is this the standard thing for all the database that they all have fact table and dimension table or is it just for business object design? I am looking for an explanation which differentiates between two and how they are related.
Edited:
Why cannot a query just get the required data from the fact table? What happens if all the information are stored in one fact table alone? What advantages we get by creating a separate fact and dimension table and joining it?
Sorry for too many questions at a time but I would like to know about the inter-relations and whys.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
维度 和 事实是OLAP数据库设计中的关键术语。
它们是许多使用这些概念的 BI 工具(例如 Microsft SSAS、Tableau Software)和语言(例如 MDX)。
有时很难知道数据是度量还是维度。例如,我们正在分析
收入
,两种情况都是可能的:净利润
、管理费用
、< code>interest利润
和 1 个维度:利润类型
(包含 3 个元素:净额、间接费用、利息)BI 分析师决定什么是每个解决方案的最佳设计。
已编辑,因为问题也在编辑中:
OLAP 解决方案通常具有语义层。该层向 OLAP 工具提供以下信息:哪些元素是事实数据、哪些元素是维度数据以及表关系。与 OLTP 系统不同,OLAP 数据库不需要正确规范化。因此,您可以从包括事实表在内的多个表中获取维度数据。从事实表中获取数据的维度名为事实维度 或退化维度。
在设计 OLAP 数据库时,您应该牢记许多概念:“星型模式”、“雪花模式”、“代理键”、“父子层次结构”……
Dimension and Fact are key terms in OLAP database design.
They are a lot of BI tools that work with these concepts (e.g. Microsft SSAS, Tableau Software) and languages (e. MDX).
Some times is not easy to know if a data is a measure or a dimension. For example, we are analyzing
revenue
, both scenarios are possibles:net profit
,overheads
,interest
profit
and 1 dimension:profit type
(with 3 elements: net, overhead, interest )The BI analyst is who determines what is the best design for each solution.
EDITED due to the question also being edited:
An OLAP solution usually has a semantic layer. This layer provides to the OLAP tool information about: which elements are fact data, which elements are dimension data and the table relationships. Unlike OLTP systems, it is not required that an OLAP database is properly normalized. For this reason, you can take dimension data from several tables including fact tables. A dimension that takes data from a fact table is named Fact Dimension or Degenerate dimension.
They are a lot of concepts that you should keep in mind when designing OLAP databases: "STAR Schema", "SNOWFLAKE Schema", "Surrogate keys", "parent-child hierarchies", ...
这是数据仓库中拥有事实表和维度表的标准。事实表包含您正在测量的数据,例如您正在求和的数据。维度表是包含您不希望在事实表中不断重复的数据的表,例如产品数据、状态、客户等。它们通过键关联:在星型模式中,事实表中的每一行包含维度表中一行的键。
That's a standard in a datawarehouse to have fact tables and dimension tables. A fact table contains the data that you are measuring, for instance what you are summing. A dimension table is a table containing data that you don't want to constantly repeat in the fact table, for example, product data, statuses, customers etc. They are related by keys: in a star schema, each row in the fact table contains a the key of a row in the dimension table.