3 ms·
I personally almost always use surrogate keys, because of having been burned by natural ones once too many times as well. Altough, sometimes I end up having a u
by Akronymus 5y ago
I personally almost always use surrogate keys, because of having been burned by natural ones once too many times as well. Altough, sometimes I end up having a unique constraint on a natural column as well, and then the temptation is there to make that the key.
But to keep it consistent I pretty much always end up using a surrogate key anyways. (I think I used natural keys like 2 times in a few years)
Unrelated: The blogs mascot is cute.
- hashimotonomora 5y agoIn my experience it’s best to work with a surrogate PK and generate a bijective customer-facing natural key.
- Akronymus 5y agoI work mainly with CRUD, and usually people want to search for specific customers, names or similar. While not necessarily bijective on its own (multiple customers, same name, for example), it narrows it down enough for the person to find the record. (Or filtering on multiple fields) So, I don't really see a need to generate a natural key.