简体   繁体   中英

Composite key to surrogate key

I have a composite natural key from the data I'm getting. Using composite_key=ID-PRODUCT_ID-CLIENT_ID-OFFICE_ID , I want to convert this key in one surrogate key.

Example:

composite_key = 55-001-234-01 to surrogate_key = 123; this is the normal scenario, sometimes the office code can change but I want to identify the record as the same Ex: composite_key = 55-001-234-02 to surrogate_key = 123.

  • How can I implement this to create an Data Warehouse?
  • How can I compare the composite key from one extraction to the other and understand if the field changed is something I can consider valid?

If two members with different OfficeID should map to the same surrogate key then it means OfficeID is simply not part of the composite key and is just a standard attribute with a type 2 (replace behaviour).

If your dimension is not too large, I'd suggest to use the simple Slowly Changing Dimension component avaialble in your ETL tool. If you don't have such a component, simply check with a lookup if the member is in your dimension is existing or not. If existing, apply an update to (eventually) change the OfficeID, if not apply an insert.

If you've a large dimension and performance issues, then it could be useful and improve performance by calculating a checksum for the set of attributes type 2. Your lookup should return this checksum and compare it to the checksum of your current row. If they are identique, the execution of the update statement is not needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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