3 ms·
They wouldn't, so my point is why do RDBMSs support so many kinds of primary keys?
by whatshisface 5y ago
They wouldn't, so my point is why do RDBMSs support so many kinds of primary keys?
- dylan604 5y agoKeys can span multiple columns, so DoB could be a differentiator if First, Last are also the same. I personally would never try to build a key like that though, but that's the only way I could see justifying its use. If you can't see a why for uses of a field that is truly more unique, then I'd suggest you just need some more imagination. Strictly not allowing it seems to me to be short sighted just because someone had the ill conceived idea to use DoB as a primary key
- whatshisface 5y agoCan you think of any good use case for a non-arbitrary primary key? You are right that first name + last name + dob is not a good way to design the system. For example someone could differentiate their twin children only by their middle name. So, what's an example of a non-integer non-arbitrary primary key?
- dylan604 5y agoNot sure exactly what you mean by non-arbitrary primary key, but... GUID/UUID FeatureName/ReleaseYear or Series/Season/Episode email phone-number SSN driverslicense#/State
- bart_spoon 5y agoI stated this elsewhere, but with some sports data, you don’t gain anything with a uniquely generated game ID. NBA teams will only play one game at most per day, and only play one other team, so if you make a key of the date and the teams playing, you uniquely identify every event. You can create an arbitrary ID for a game if you want, but it’s not actually giving you information you don’t have, and therefore is entirely redundant.
- ipaddr 5y agoUsing a generated pagename as a key. You create a cms. You store each page with a 16 character name as the key and you use that as the url/pagename. What about storing the ip for login attempts. You store the ip and date and use that information to rate limit. The ip is the primary id. Password reset, you store the unique code you sent in the email as the key. Country codes. The 2 or 3 short name makes as a key over a number if you want to limit joins. Bitcoin key. Anything token, key related, anywhere where you want to enforce no duplicates like a ssn.
- brantam 5y ago> Can you think of any good use case for a non-arbitrary primary key? Login names; Vehicle registration numbers; flight numbers; domain names; file names; ip addresses. Keys are used in those cases where the enforcement of uniqueness is important for data integrity and identification purposes.