Where UUIDs came from
UUID stands for Universally Unique Identifier.
The same 128-bit format is often called a GUID.
The problem UUIDs solve
An auto-incrementing database key works well inside one database.
That property is useful for event messages.
Format and versions
A canonical UUID is 16 bytes.
550e8400-e29b-41d4-a716-446655440000v1 · time-based
Combines a timestamp.
v4 · random
Uses secure random bytes.
v7 · time-ordered
Places a timestamp first.
Choosing and using a UUID
Use the version that follows the requirements:
- Choose v4 for general-purpose opaque identifiers.
- Choose v7 when records are sorted by creation time.
- Avoid v1 for public identifiers.
- Store UUIDs efficiently.
A UUID is an identifier, not a secret.