I need to create a Directory table for a project within an institute. How shall I implement a primary key, given the following?
a) The Directory must be referenced by many other tables in many other databases, some of which will not reside in the same instance of SQL Server.
b) The Institute provides InstitutePersonKey, which is guaranteed to represent a specific person, and only that person, forever. However,
c) Some people need to be added to one or more of the referencing databases, and therefore to the Directory, before they obtain an InstitutePersonKey.
d) Some, but not all, of these will eventually obtain an InstitutePersonKey.
e) Many of the referencing tables will have more than one column referening the primary key of the Directory.
Based on what I’ve read and tried,
a. I cannot use foreign keys to reference the Directory from other databases.
b. Even if a. is wrong, I cannot use cascading updates in those references.
c. Even if a. and b. are both wrong, I cannot have two columns in the same table each of which references the Directory with cascading updates, even if the table is in the same database as the Directory.
This suggests that creating a fake InstitutePersonKey of my own, to be replaced with a real one if/when the institute issues one, is likely to be cumbersome and subject to error.
One approach is
1. Make up my own primary key (for example [last name]+’|’+[first name]+seq where seq is an integer incremented to avoid duplicates).
2. Add a InstitutePersonKey column, which is constrained to be either
a. NULL, or
b. a unique valid reference to InstitutePersonKey in the Institute data warehouse.
Suggestions would be greatly appreciated.