3 ms·
Can 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
by whatshisface 5y ago
Can 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.