What Is a UUID?
A UUID is a 128-bit identifier designed to be unique across systems without requiring a central coordinating authority.
The problem UUIDs solve
Many systems need to assign unique identifiers to records — users, orders, sessions — without a central database sequence handing out the next number. That becomes especially important in distributed systems, where multiple servers might need to generate IDs independently without coordinating with each other in real time. UUIDs solve this by making collisions so statistically unlikely that no coordination is needed at all.
How UUIDs are formatted
A UUID is a 128-bit value, typically displayed as 32 hexadecimal digits grouped into five sections separated by hyphens, in the pattern 8-4-4-4-12, for example `f47ac10b-58cc-4372-a567-0e02b2c3d479`.
The different versions
The UUID specification defines several versions with different generation strategies. Version 1 is based on a timestamp plus network information. Versions 3 and 5 are generated deterministically by hashing a namespace and a name (so the same input always produces the same UUID). Version 4 is generated from random or pseudo-random numbers and requires no external input at all, which is why it's the most commonly used version in everyday application development.
Are collisions really impossible?
Not impossible, but negligible. A version 4 UUID has 122 random bits, giving roughly 5.3 undecillion possible values. Even generating billions of UUIDs, the probability of ever seeing a duplicate is astronomically small — small enough that UUIDs are trusted as primary keys in production databases worldwide.