Databases 101 : What are UUIDs? should we care?

The great dilemma, UUID vs serial as a primary key :P
UUIDs Structure
xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx (M is version N is variant)

All the UUIDs follow the same [8] [4] [4] [4] [12] bits format
  1. TimeLow : 4 Bytes (8 hex chars) from the integer value of the low 32 bits of current UTC timestamp ~6157329e
  2. TimeMid : 2 Bytes (4 hex chars) from the integer value of the middle 16 bits of current UTC time ~ 608a
  3. TimeHighAndVersion : 2 Bytes (4 hex chars) 4-bit “version” in the most significant bits, followed by the high 12 bits of the time ~ 4b40
    I don't know what a version number is neither I know what is multiplexing.
  4. ClockSequenceHiAndRes && ClockSequenceLow : 2 Bytes (4 hex chars) where the 1 through 3 (significant) bits contain the “variant” of the UUID version being used, and the remaining bits contain the clock sequence ~ b4b0
  5. Node : 6 bytes (12 hex chars) that represent the 48-bit “node id”, which is usually the MAC address of the host hardware that generated it. ~ 0a31cca02bf1
6157329e-608a-4b40-b4b0–0a31cca02bf1
  1. Why did I dig into so many facts about UUIDs, is it of any use 🥱?
    I wanted to understand this beautiful article here about the tradeoffs of considering UUID vs Serials as a primary key, which I was not able to understand without structuring these facts together ✌️.

--

--

--

Cooking Dreams | Engineering at Disney+ Hotstar Github.Handle:https://github.com/LuGO0

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Redis : Your db for in memory

Image-building best practices

Using Python to automate the registration process of my university’s lab classes

Using the CQRS Pattern in C#

Building a Queue Network on Neo4j Cypher and APOC

Command line editing keyboard shortcuts

Configure Hadoop Cluster Using Ansible Playbook.

X swap protocol is a amazing project.I

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Saurabh Kumar

Saurabh Kumar

Cooking Dreams | Engineering at Disney+ Hotstar Github.Handle:https://github.com/LuGO0

More from Medium

Normalization in Database

Fundamental concepts of database design

How To determine the order of indexes when using Composite Key

From Tunnel Engineering to APIs