> [!tldr] UUID, Nanoid, Word combos, and a fun idea about a syllable-based system Unique identifiers are hugely important. [[Ambiguity]] is bad for engineered systems and [[Primary Key]]s are good. [[Surrogate Keys]] are often necessary, and there's no single "best" system for how to implement your keys. I'm going to separate things out into 2 broad categories and a few basic families. # Closed-World Systems For any closed system, you don't have to consider [[Key Collisions]] with things outside the system. For these situations you can control & thus guarantee that keys will remain unique. ## Natural Keys It's possible that the system affords some form of natural [[Candidate Key]]. People inside a family probably don't share a given name, so simply saying 'Aaron' in my house is enough of a unique identifier. ## Numerical Monotonically Increasing `1,2,3,4,...` - used in many [[Relational Databases]]. Sometimes these schemes have a [[Sigil]] to make it more obvious saying "this is a key". Things like the `Gid` for [[Wikidata]] come to mind. Or employee or student ids. ## Alphabetical Monotonically Increasing `...x,y,z,aa,ab,ac,...` - used sometimes in place of numerical systems ## Combinational Systems `A1, A2, B1, B2...` - for 2d grids, like [[Spreadsheet|Excel]]. ## Hash Systems You can compute the [[Hash Table|Hash]] of a thing then use its result as its unique ID. This is perhaps the main purpose of a hash, really. # Open-World Systems What's more interesting is when you cannot know every key. Open-world systems are where keys generated from any sort of source, in combination with keys from every other source, must remain unique. In theory, you cannot guarantee with 100% confidence that keys will be unique. In practice, there's only so many possible things generating keys. ## Byte Combinations Systems designed to be stored and read as [[Binary]] bytes. [[UUID]] fits in here - where each character actually is hexadecimal. `005564f7-d1b7-42b3-a2a7-001cbd383dc5` This gives you 16 different values per unit of length. So you get `16^n` combinations for length `n`. ## Character Combinations Systems designed to be stored and read as characters using a [[Character Encoding]]. These are less efficient from a "raw number of bytes" perspective, but *more* efficient from a "fits on your computer screen nicely" perspective. [[NanoID]] fits in here. `58-uWSZGohwFHQtn5418y` The number of combinations possible depends on the alphabet you use, which there is no universal set for. [[Alternate Counting Bases]] contains some example alphabets. Nanoid's alphabet is 64 characters long. `(a-z, A-Z, 0-9, -, _)` resulting in `64^n` combinations for length `n`. ## Syllable Combinations The reason I wrote this note. I've never seen this in the wild. Closest I've seen would be a password manager app generating "pronounceable" passwords. I can't remember which one did that, though. `bla-dee-frup-chum` You could construct a pronounceable identifier by treating **syllables** as the unique building block. This may be the most efficient system (hypothetically, although doubtful in reality) in a world where unique identifiers had to be spoken out loud to people. In reality the [[#Word Combinations]] approach is used for that. The number of possible syllables is... hard to figure out, and dependent on the language. There's probably, roughly 10,000 or so. So `10000^n` combinations for length `n`. ## Word Combinations This is a system used by [[Git]]Hub, [What3Words](https://what3words.com), and various other places I've run across. This system produces IDs like: `boredom committed bellyful` Per Google AI - What3Words uses a dictionary of 40,000 words, resulting in `40000^n` combinations for length `n`. **** # More ## Source - self - https://en.wikipedia.org/wiki/What3words#cite_note-wired2018-26