是否可以在事实维度 DWH 设计中使用系统版本时间 table?
Is it possible to use system-versioned temporal table in the fact-dimension DWH design?
假设我想在 DWH 系统中实现 SCD type2 历史维度 table(或者我应该说 table 具有 SCD type2 属性),目前我一直将其实现为 "usual table" 带有 natural key
+ primary surrogate key
+ datefrom
+ dateto
+ iscurrent
附加列。
其中
- 需要
primary surrogate key
才能将其用作所有事实 table 和 中的外键
datefrom
+ dateto
+ iscurrent
列以跟踪历史记录。
现在我想在事实维度 DWH 设计中使用系统版本时间 table,但是 MSDN 据说:
A temporal table must have a primary key defined in order to correlate
records between the current table and the history table, and the
history table cannot have a primary key defined.
所以看起来我应该使用带有 primary surrogate key
生成 "on the fly" 或另一个 ETL 过程的视图,但我不喜欢这两个想法...
也许还有其他方法?
您将在数据仓库的持久暂存区域中使用 Temporal Table。然后您可以简单地应用来自源系统的更改,而不会丢失任何历史版本。
然后在查询或构建维度数据集市时,您可以将事实连接到维度的当前或历史版本。请注意,您 不需要 代理键来执行此操作,但您可以生成它们以简化和优化对维度模型的查询。您可以使用
这样的表达式生成代理键
ROW_NUMBER () OVER (ORDER BY EmployeeID, ValidTo) AS EmployeeKey
然后像往常一样在加载事实 table 时加入维度 table。
但有趣的是,这可以 推迟 您的维度建模和 SCD 类型的选择,直到您真正需要它们为止。减少和推迟数据集市的设计和实施可以帮助您更快地取得增量进展。您可以自信地使用持久暂存区域(或者 'data lake',如果您更喜欢该术语)的视图来交付一组初始报告,同时您对数据集市的设计思维也在不断发展。
假设我想在 DWH 系统中实现 SCD type2 历史维度 table(或者我应该说 table 具有 SCD type2 属性),目前我一直将其实现为 "usual table" 带有 natural key
+ primary surrogate key
+ datefrom
+ dateto
+ iscurrent
附加列。
其中
- 需要
primary surrogate key
才能将其用作所有事实 table 和 中的外键
datefrom
+dateto
+iscurrent
列以跟踪历史记录。
现在我想在事实维度 DWH 设计中使用系统版本时间 table,但是 MSDN 据说:
A temporal table must have a primary key defined in order to correlate records between the current table and the history table, and the history table cannot have a primary key defined.
所以看起来我应该使用带有 primary surrogate key
生成 "on the fly" 或另一个 ETL 过程的视图,但我不喜欢这两个想法...
也许还有其他方法?
您将在数据仓库的持久暂存区域中使用 Temporal Table。然后您可以简单地应用来自源系统的更改,而不会丢失任何历史版本。
然后在查询或构建维度数据集市时,您可以将事实连接到维度的当前或历史版本。请注意,您 不需要 代理键来执行此操作,但您可以生成它们以简化和优化对维度模型的查询。您可以使用
这样的表达式生成代理键 ROW_NUMBER () OVER (ORDER BY EmployeeID, ValidTo) AS EmployeeKey
然后像往常一样在加载事实 table 时加入维度 table。
但有趣的是,这可以 推迟 您的维度建模和 SCD 类型的选择,直到您真正需要它们为止。减少和推迟数据集市的设计和实施可以帮助您更快地取得增量进展。您可以自信地使用持久暂存区域(或者 'data lake',如果您更喜欢该术语)的视图来交付一组初始报告,同时您对数据集市的设计思维也在不断发展。