Say 2 users have an entry on their local device, but by some chance, their entry had the same uuid generated. What should happen when both users they try to upload them to a central data base
Is it normal to just "re-id" one of the entries?
Say 2 users have an entry on their local device, but by some chance, their entry had the same uuid generated. What should happen when both users they try to upload them to a central data base
Is it normal to just "re-id" one of the entries?
The chance of two devices generating duplicate UUIDs is so small that most systems will ignore the possibility. From How unique is UUID?:
after generating 1 billion UUIDs every second for the next 100 years, the probability of creating just one duplicate would be about 50%.
This of course is dependent on the volume of data being generated by devices, if these are some types of sensor that generate huge volumes of records (e.g. on aeroplane engines) then the chance of a non-unique UUID starts to become a possibility.
If that's the case and you need to be sure of 100% uniqueness in the IDs then as others have mentioned you'll need to do one of the following:
It seems that you're letting multiple devices generate IDs which should be unique for the entire application.
If you can check for entry upload conflicts, and prevent the upload of an entry with an existing unique ID, then you can handle the error by generating another ID and trying again. (This may be viable especially if you can distinguish the entries by the users that are uploading those entries, and not just by their unique IDs.) If that is an option for you, then it's enough to use random numbers (such as random UUIDs) as unique entry IDs. Random IDs are also appropriate if you can tolerate the risk of generating the same identifier for different entries.
See also what I have to say about unique random identifiers.