简体   繁体   English

在SSIS中从SCD1和SCD2维加载事实表

[英]Loading Fact tables from SCD1 and SCD2 Dimension in SSIS

I am finding it difficult to understand how you get the history data from a fact table join to a Dimension that has Type2 and Type1 for historic records that have changed. 我发现很难理解您是如何从事实表中获取历史数据的,该事实表已连接到具有已更改的历史记录的Type2和Type1的Dimension。 Currently I have a Surrogate Key and Business Key in the Dim. 目前,我在点心中有一个代理密钥和业务密钥。 The Fact Table has the Surrogate Key the Fact table and I am using SSIS Lookup Component currently to bring back the row that has the CurrentFlag set to Yes. 事实表具有事实表的代理键,我目前正在使用SSIS查找组件来带回将CurrentFlag设置为“是”的行。

However I am joining on the Business Key in the Lookup and returning the Surrogate. 但是,我要在查找中加入业务密钥并返回代理。 Which I know is the main reason I can't get history, however if I Join on the Business Key as I am currently doing and return the Business Key also, SSIS component will only bring back just one row, regardless of how many versions of history you have against that Business Key. 我知道这是我无法获取历史记录的主要原因,但是,如果我按照目前的方式加入业务密钥并返回业务密钥,那么无论有多少版本的SSIS组件,SSIS组件都只会返回一行。您针对该业务密钥的历史记录。

What I want to know or have been told is to use lookups to populate fact tables, however this doesn't seem to really give me the history as it will only return one row regardless. 我想知道或被告知的是使用查找来填充事实表,但是这似乎并没有真正给我历史,因为无论如何它只会返回一行。 So I Just want to know how to return historic date between a fact and a dimension in SSIS. 因此,我只想知道如何在SSIS中返回事实与维度之间的历史日期。

Thank you 谢谢

There's a few caveats when it comes to historical dimensions. 关于历史维度,有一些警告。 Your end users will need to know what it is you are presenting, and understand the differences. 您的最终用户将需要知道您要呈现的内容,并了解它们之间的差异。

For example, consider the following scenario: 例如,请考虑以下情形:

Customer A is located in Las Vegas in January 2017. They place an order for Product 123, which at that time costs $125. 客户A于2017年1月位于拉斯维加斯。他们下达了产品123的订单,当时的价格为125美元。

Now, it's August. 现在是八月。 In the meantime, the Customer moved to Washington DC in May, and Product 123 was updated in July to cost $145. 同时,客户在5月移至华盛顿特区,产品123在7月更新为145美元。

Your end users will need to inform you what they want to see. 您的最终用户将需要通知您他们想看什么。 In case you are not tracking history whatsoever, and simply truncate and load everything on a daily basis, your order report would show the following: 如果您不跟踪任何历史记录,而只是每天截断并加载所有内容,则您的订单报告将显示以下内容:

Customer A, located in Washington DC placed an order for $145 in January. 位于华盛顿特区的客户A在1月份下了$ 145的订单。

If you implement proper history tracking, and implemented logic to identify the start- and end-date of a row in a dimension, you would join the fact table to the dimension using the natural key as well as the proper date interval. 如果实施适当的历史记录跟踪并实施逻辑以识别维中某行的开始日期和结束日期,则可以使用自然键以及适当的日期间隔将事实表连接到维。 This should return you a single value for every dimension row in the fact table. 这将为事实表中的每个维度行返回一个值。 IF it returns more, you have overlapping dates. 如果返回更多,则日期重叠。

Can you show us the logic where you receive only a single value from the lookup, even though you have more records? 您能否向我们展示逻辑,即使您有更多记录,在该逻辑中您也只能从查找中接收单个值?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM