Reputation: 87
In my Spring Boot Java application, in the db, there are entries added regularly to an entity (XEntity) with some Integer field that is unique ("some_fieldId"). There are already a lot of entries added (autoincremented from 1 to about 6000000).
Now, in a new feature, some other third party will add entries too but I need to be sure that "some_fieldId" doesn't already exist. They naturally wanted to start with the first id=1.
What strategy may I suggest to them for generating that Integer field ("some_fieldId") in order to preserve unicity?
Something that I have in my mind is to generate only negative ids, but they don't agree too much with that.
Upvotes: 0
Views: 95
Reputation: 95
You should pair-up XEntity with name of unique thirdparty column as a pair-unique constraint such that Id 1->+inf is unique for all third parties involved. If Id is primary key then use composite key as primary key.
Upvotes: 1