# Change in Primary Key at source

**URL:** <https://forum.data-community.org/t/change-in-primary-key-at-source/1288>\
**Category:** Data Vault 2.0\
**Tags:** business-key, hub\
**Created:** [May 2, 2024, 8:23am UTC](https://forum.data-community.org/t/change-in-primary-key-at-source/1288 "2024-05-02T08:23:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpols](https://avatars.discourse-cdn.com/v4/letter/m/ebca7d/32.png) [@mpols](https://forum.data-community.org/u/mpols)\
**Post date:** [May 2, 2024, 8:23am UTC](https://forum.data-community.org/t/change-in-primary-key-at-source/1288/1 "2024-05-02T08:23:41Z")

</div>

One of our hubs is central to rest of our Data Vault. Meaning, 80% of our satellites are hanging off this hub.

Consultants who came in first to build this 1st one of our hubs had little idea as to what data field is ideal to use for Hub hash, so they ended up choosing something that could change once in say 2 years for unknown reasons. We plan to remodel the hub in near future and use a more stable column for Hub hash.

For historical data, Given that our datasets are small ~ 50K rows per satellite and wondering if it is advisable to simply update the satellite data to point to the new key? (May be not, but thought I’d ask)

If not, is there a simpler way to point historical data to new key without undertaking a herculean effort.

---

<div class="post-metadata">

**Author:** ![patrickcuba](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.data-community.org/patrickcuba/32/19_2.png) [@patrickcuba](https://forum.data-community.org/u/patrickcuba)\
**Post date:** [May 16, 2024, 1:08am UTC](https://forum.data-community.org/t/change-in-primary-key-at-source/1288/2 "2024-05-16T01:08:21Z")

</div>

I think refactoring will help you in the long run — imagine having to write queries to handle data differently at a point in time just based on a legacy DV

---

<div class="post-metadata">

**Author:** ![mpols](https://avatars.discourse-cdn.com/v4/letter/m/ebca7d/32.png) [@mpols](https://forum.data-community.org/u/mpols)\
**Post date:** [May 16, 2024, 5:13pm UTC](https://forum.data-community.org/t/change-in-primary-key-at-source/1288/4 "2024-05-16T17:13:07Z")

</div>

Hi @patrickcuba

Thank you very much for responding. I wanted to make sure I’m on the right track. Our plan is to :

Create a new hub with a stable primary key and a refactor existing data to use the new hub and key.

–Brief plan

1. Hub called `h_property` with `PropertyNumber` as the current business key, and we want to change it to use `propertyid` as the new business key.

2. ##Analyze Impact##:

3. ##Create a New Hub##:  
– SQL  
CREATE TABLE h\_property\_New (  
propertyhash char(32),  
propertyid VARCHAR(36) PRIMARY KEY,  
LoadDateTime DATETIME,  
RecordSource VARCHAR(50)  
);

4. ##Data Migration##:  
– SQL  
INSERT INTO h\_property\_New (propertyhash,propertyid, LoadDateTime, RecordSource)  
SELECT new\_hash\_from\_new\_key, propertyid, LoadDateTime, RecordSource  
FROM h\_property;

5. ##Update Links##:  
– SQL  
ALTER TABLE l\_property\_customer ADD propertyid VARCHAR(36);

6. ##Update Satellites##:

7. ##Update ETL Processes##:

8. ##Deprecate the Old Hub##:
