I store a list of names in the database. The list does not have any primary key for each record. These names are then used by another program and so require a primary key to be used as a foreign key.
The list is owned by a third party which is beyond our influence so we can't force them to provide a primary key.
I was using an incremental number to have PK but it has recently been noticed that the new records can be inserted anywhere in the list and so the incremental approach would fail. Hash codes can not be used as they are not guaranteed to be stable.
Is there any way i can generate a stable Primary Key for these records which can then be traced back with the name OR any other approach to refer back to a name in the list?
For example
On day 1 the list is like below
- Oliver
- Jack
- Harry
- Jacob
- Charlie
Assume that 963 is the key (as hash code) for Oliver and this code has been saved by program XYZ in its storage to refer back to Oliver.
On other day a new name Oscar has been added in the middle
- Oliver
- Jack
- Oscar
- Harry
- Jacob
- Charlie
Now the key for Oliver is 852 because Hash code is not guaranteed to be stable and sequencing has been disturbed too hence the program XYZ can not refer back to Oliver using the key 963.