Universally Unique Identifiers (UUIDs) are standard for identifying information in computer systems.
What is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit label used for information in computer systems. The term GUID (Globally Unique Identifier) is also used, typically in Microsoft systems. They are designed to be unique across all space and time, minimizing the risk of duplication.
What is a UUID v4?
Version 4 UUIDs are generated using random numbers. There are approximately 5.3 x 10^36 possible v4 UUIDs, making the probability of a collision (generating the same UUID twice) practically zero. This makes them ideal for generating unique keys for databases, sessions, or transactions without needing a central authority.
Can UUIDs be duplicated?
While theoretically possible, the probability is so astronomically low that it is effectively impossible in practice. To put it in perspective, you would need to generate billions of UUIDs per second for many years to have even a slight chance of a collision.
Why use UUIDs instead of auto-incrementing IDs?
UUIDs allow you to generate unique IDs without checking a central database, which is great for distributed systems. They also don't reveal information about your data (like how many records you have), which can be a security advantage over sequential IDs.