3 ms·
> I have never understood why RDBs have such general concepts of primary keys, where you can for example let date of birth be a primary key, when in every schem
by dragonwriter 5y ago
> I have never understood why RDBs have such general concepts of primary keys, where you can for example let date of birth be a primary key, when in every schema I have ever designed or seen, all rows get unique integer IDs anyway.
Because sequential integer surrogate keys aren't always a good idea, e.g.:
1. Certain logically-unique join tables, where the foreign keys to the joined tables form an obvious composite primary key.
2. Cases with natural primary keys for basic data; A date might not be a good primary key if its the DoB in a table of people, but its an excellent primary key in a calendar table.
3. Even when you need surrogate keys, sometimes you need them to be able to be generated in a distributed manner, so you want something like UUID/ULID instead of sequential integers.