Using secondary id as foreign key to other table

database-designforeign keyprimary-key

So I have a Customer table that is linked to different tables. For instance, a Configuration table is linked to Customer table.

Instead of using Customer Id as foreign key to the Configuration table, I would like to introduce a secondary id called Reference. This Reference has a value similar to GUID and would like to use this as Foreign Key to the Configuration table. The reason behind this is because I don't want to use the Id of the Customer table. We use integer as a data type for this and I don't want to expose this.

What could be the possible complications on implementing this approach?

Best Answer

It's not complicated to do. You need to create the Reference ID as an alternate key in the Customer table with a unique constraint. Then you can use Reference ID as a foreign key to the Configuration table. I generally try to avoid this however as it can get confusing and harder to maintain the data model.