Universally Unique IDs (UUIDs) use random numbers to create unique IDs. UUIDs use more storage, but they provide a good solution for distributed databases and security.

Changing the schema for large relational databases costs companies millions of dollars every year. Relational databases are highly intertwined, so one small change can have unexpected, cascading effects.

The foundation for a table in a relational database is the primary key. Because of its importance, we have to give special consideration to how we select our primary keys.

In this article I’ll discuss why primary keys are important, different types of keys you can use, and a primary key with values that are guaranteed to have never, ever been used in the entire universe (with a 1/10^37 chance of error).

Table of Contents:

  1. Understanding Keys in SQL
  2. Creating a Primary Key with PostgreSQL
  3. A Universally Unique ID? Intro to UUIDs
  4. Creating a UUID Primary Key Using uuid-osp - PostgreSQL Example
  5. Alternative to UUID - Auto-Increment Primary Key
  6. UUID vs Auto-Increment Primary Key

#postgresql #sql #developer

A Complete Guide to UUIDs in Postgres
1.90 GEEK