事实 Table 具有非测量数据
Fact Table With Non-Measure Data
在下面的模型中,描述是一个自由文本字段,用于描述员工缺勤的原因。
这个描述字段是否可以在事实table中并被视为退化维度?
该值将主要用于列表报告或使用词云的仪表板。
不,描述性文本列不应包含在事实 table 中。相反,此列应包含在维度中。
如果您要报告标签(关键词),我会为这些标签创建一个维度并解析描述以找到与事实相关联的适当标签。例如,我从描述中看到 2 个标签(葬礼和生病)。我会创建一个维度 DimAbsentReason 来包含这些标签。
如果您需要保留实际的描述,那么您可以为描述创建一个维度 (DimAbsentReason) 并与事实进行适当的关联 table。
您的设计是正确的。将自由文本作为退化维度纳入事实并没有错table。
在维度中存储评论才有意义只有 如果评论是结构化的(即,如果它们是标准化的并且有效地与事实记录有 1:M 关系) .如果它们存储为自由文本,因此与事实有 1:1 关系,那么将它们转换为维度是一个大错误 - 你最终会得到与事实 table 一样高的维度。在适当的设计中,尺寸是宽而短的,而事实 table 是窄而高的。高尺寸是一个问题,因为它们在性能方面非常昂贵。
它们也很难用。假设您正在使用 PowerBI 等报告工具。如果您将自由文本作为退化维度存储在事实 table 中,使用起来简单直观 - 我可以这样写:
Reason for Absence = SELECTEDVALUE( Fact[Description])
评论将正确显示在报告中。完成。
但是,如果您将相同的评论存储在一个维度中,那么,祝您好运,了解如何将它们添加到报告中。
数据仓库工具包第 3 版的第 65 页说明如下:
Text Comments Dimension: Rather than treating freeform comments as textual metrics in a fact table, they should be stored outside the fact table in a separate comments dimension (or as attributes in a dimension with one row per transaction if the comments’ cardinality matches the number of unique transactions) with a corresponding foreign key in the fact table.
金博尔,拉尔夫;罗斯,玛吉。数据仓库工具包:维度建模权威指南(第 65 页)。威利。 Kindle 版。
第 47 页有这个退化维度的例子:
For example, when an invoice has multiple line items, the line item
fact rows inherit all the descriptive dimension foreign keys of the
invoice, and the invoice is left with no unique content. But the
invoice number remains a valid dimension key for fact tables at the
line item level.
金博尔,拉尔夫;罗斯,玛吉。数据仓库工具包:维度建模权威指南(第 47 页)。威利。 Kindle 版。
在下面的模型中,描述是一个自由文本字段,用于描述员工缺勤的原因。
这个描述字段是否可以在事实table中并被视为退化维度?
该值将主要用于列表报告或使用词云的仪表板。
不,描述性文本列不应包含在事实 table 中。相反,此列应包含在维度中。
如果您要报告标签(关键词),我会为这些标签创建一个维度并解析描述以找到与事实相关联的适当标签。例如,我从描述中看到 2 个标签(葬礼和生病)。我会创建一个维度 DimAbsentReason 来包含这些标签。
如果您需要保留实际的描述,那么您可以为描述创建一个维度 (DimAbsentReason) 并与事实进行适当的关联 table。
您的设计是正确的。将自由文本作为退化维度纳入事实并没有错table。
在维度中存储评论才有意义只有 如果评论是结构化的(即,如果它们是标准化的并且有效地与事实记录有 1:M 关系) .如果它们存储为自由文本,因此与事实有 1:1 关系,那么将它们转换为维度是一个大错误 - 你最终会得到与事实 table 一样高的维度。在适当的设计中,尺寸是宽而短的,而事实 table 是窄而高的。高尺寸是一个问题,因为它们在性能方面非常昂贵。
它们也很难用。假设您正在使用 PowerBI 等报告工具。如果您将自由文本作为退化维度存储在事实 table 中,使用起来简单直观 - 我可以这样写:
Reason for Absence = SELECTEDVALUE( Fact[Description])
评论将正确显示在报告中。完成。
但是,如果您将相同的评论存储在一个维度中,那么,祝您好运,了解如何将它们添加到报告中。
数据仓库工具包第 3 版的第 65 页说明如下:
Text Comments Dimension: Rather than treating freeform comments as textual metrics in a fact table, they should be stored outside the fact table in a separate comments dimension (or as attributes in a dimension with one row per transaction if the comments’ cardinality matches the number of unique transactions) with a corresponding foreign key in the fact table.
金博尔,拉尔夫;罗斯,玛吉。数据仓库工具包:维度建模权威指南(第 65 页)。威利。 Kindle 版。
第 47 页有这个退化维度的例子:
For example, when an invoice has multiple line items, the line item fact rows inherit all the descriptive dimension foreign keys of the invoice, and the invoice is left with no unique content. But the invoice number remains a valid dimension key for fact tables at the line item level.
金博尔,拉尔夫;罗斯,玛吉。数据仓库工具包:维度建模权威指南(第 47 页)。威利。 Kindle 版。