What are the trade-offs of using a UUID or Auto-increment ID (Surrogate) versus a Social Security Number or Email (Natural) as a Primary Key?
Last updated
Surrogate keys (auto-increment or UUID, system-generated and meaningless) are immutable, compact, and expose no real-world data. They need a join to get meaningful values.
Natural keys (SSN, email) carry business meaning but can change and cascade through foreign keys. They also pose privacy risks and are wider and slower to index.
Common practice: use a surrogate primary key and enforce the natural attribute with a separate
UNIQUEconstraint.
- https://medium.com/towardsdev/sql-trade-off-natural-keys-vs-surrogate-keys-9e0cb1c73c51
- https://medium.com/@reliabledataengineering/surrogate-keys-auto-increment-vs-uuid-vs-hash-keys-vs-natural-keys-1285eceab0d9
- https://dataarchitect.studio/essays/surrogate-keys-vs-natural-keys/
- https://liambx.com/blog/why-surrogate-keys-win
- https://apxml.com/courses/data-modeling-schema-design-analytics/chapter-3-advanced-dimension-handling/surrogate-keys-vs-natural-keys
- https://www.youtube.com/shorts/JO-RrGQFypU