Why is better to use an UUID to store unique id values? What are the benefits?
The main advantage of using UUIDs is that you can create a UUID and use it to identify something, such as a row in a database, with near certainty that the identifier will not exist in another row in your system or anyone else's.
A UUID – that's short for Universally Unique IDentifier, by the way – is a 36-character alphanumeric string that can be used to identify information (such as a table row).
UUIDs as primary key aren't a slam drunk, but do have some advantages: The fact that they're random means that they don't rely on a single sequence to be generated. Multiple entities can generate IDs independently, but still store them to a shared data store without clobbering each other.
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer systems. You can create a UUID and use it to uniquely identify something.
Two reasons.
A regular ID is only unique within your table inside of your system. If you ever need to integrate systems there is going to be conflict. UUID is guaranteed to be unique across systems.
A second reason is often you don't want people to know how many records you have in your system. If you have an id with 1,2,3,4,5,6,ect someone can easily figure out how big or small your system is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With