Relationships are the basis of relational database design. When set up properly, table relationships will ensure your database runs like a well oiled machine. However, sometimes we run into systems where relationship keys are open to the user, exposing data to the risk of human error if a relationship is changed improperly. It’s sometimes desirable to refactor these relationships to use a proper artificial key relationships to connect tables, a laborious task depending on the size of your database. This post discusses a convenient trick to populate Primary Keys, a reminder about mismatched data types, and a modular script to help populate foreign keys when refactoring a key relationship.