UUID
A Universally Unique Identifier (UUID) is a 128-bit number used to identify information in computer systems. UUIDs are designed to be unique across both space and time, with an extremely low probability of duplication.
History
The concept of UUIDs originated from the Open Software Foundation (OSF) Distributed Computing Environment (DCE) in the late 1980s. The idea was to have a standard method for generating unique identifiers that could be used across different systems and software applications:
- 1980s - Introduction of DCE UUIDs by OSF.
- 1998 - Internet Engineering Task Force (IETF) published RFC 2518, which introduced the WebDAV protocol and included the use of UUIDs for versioning.
- 2005 - RFC 4122 was published, defining the standard for UUIDs, which remains the current standard.
Versions
UUIDs come in several versions, each with a different method of generation:
- Version 1 - Based on time and MAC address.
- Version 3 - Uses MD5 hashing.
- Version 4 - Randomly generated.
- Version 5 - Uses SHA-1 hashing.
- Other Versions - There are other less commonly used versions like version 2, which is based on DCE security.
Format
The standard format for a UUID is:
xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
- 'x' represents a hexadecimal digit.
- 'M' indicates the version number.
- 'N' indicates the variant of UUID.
Generation
UUIDs can be generated using various algorithms, depending on their version:
- Time-based - Incorporates the time, clock sequence, and node (typically the MAC address).
- Name-based - Uses hashing algorithms like MD5 or SHA-1 to generate UUIDs from a namespace and name.
- Random or Pseudo-random - Generates a UUID from random or pseudo-random numbers.
Applications
UUIDs are widely used in:
- Database keys to ensure uniqueness across different databases or systems.
- File systems for file identification.
- Software development for generating unique identifiers in applications.
- Distributed systems to coordinate unique identifiers across different nodes.
Advantages
- Uniqueness: High probability of being unique across space and time.
- Decentralized Generation: No need for a centralized authority to generate them.
- Sortability: Time-based UUIDs can be sorted by generation time.
Disadvantages
- Size: UUIDs are 128 bits, which is relatively large for some applications.
- Predictability: Time-based UUIDs can reveal the approximate time of generation.
External Links
Related Topics