UUID


Universally Unique Identifier (UUID) is a 128-bit label used for information in computer systems. This has standards for generating the identifier for uniqueness and independent code generation. Its existence since year 1980 with Appollo computer used in Network Computer System and later adapted by Open Software Foundation in Distributed Computing Environment.

There are other standards organizations has registered and make the identifier specification such as RFC, ITU and IETF.

UUID stands for Universal Unique Identifier defined by RFC 4122

Format:

FieldNDR Data TypeOctet #Note
time_lowunsigned long0-3The low field of the timestamp.
time_midunsigned short4-5The middle field of the timestamp.
time_hi_and_versionunsigned short6-7The high field of the timestamp multiplexed with the version number.
clock_seq_hi_and_reservedunsigned small8The high field of the clock sequence multiplexed with the variant.
clock_seq_lowunsigned small9The low field of the clock sequence.
nodecharacter10-15The spatially unique node identifier.

how to use?

we can generate UUID in any standard programming language or general-purpose application software.

we are going to look into the following:

Database system:

Database – function – data type

  • Oracle – sys_guid() – RAW(16)
  • SQL Server – NEWID() – uniqueidentifier
  • PostgreSQL – gen_random_uuid() – UUID
  • MySQL – UUID() – BINARY(16)

Programming language:

Python:

The uuid module provides immutable UUID objects (the UUID class) and the following functions 

uuid1()uuid3()uuid4()uuid5() 

are for generating version 1, 3, 4, and 5 UUIDs as specified in RFC 4122.

note: version 1 may have the privacy issue. please use these functions with full understanding.

acronyms:

  • RFC – Request for Comment
  • ITU – International Telecommunication Union
  • IETF – Internet Engineering Task Force

Ref:

Universally unique identifier – Wikipedia

stackoverflow.com – uuid-in-python

Leave a comment