surrogate-key

ID Best Practices for Databases

↘锁芯ラ 提交于 2019-11-30 04:03:43
问题 I was wondering what the best practices were for building and storing IDs. A few years ago, a professor told me about the dangers of a poorly constructed ID system, using the Social Security Number as an example. In particular, because SSNs do not have any error detection... it is impossible to tell the difference between a 9-digit string and a valid SSN. And now government agencies need things like Last Name + SSN or Birthday + SSN to keep track of your data and ensure its verification. Plus

Relational database design question - Surrogate-key or Natural-key?

人盡茶涼 提交于 2019-11-26 21:05:20
Which one is the best practice and Why ? a) Type Table, Surrogate/Artificial Key Foreign key is from user.type to type.id : b) Type Table, Natural Key Foreign key is from user.type to type.typeName : I believe that in practice, using a natural key is rarely the best option. I would probably go for the surrogate key approach as in your first example. The following are the main disadvantages of the natural key approach: You might have an incorrect type name, or you may simply want to rename the type. To edit it, you would have to update all the tables that would be using it as a foreign key. An

Relational database design question - Surrogate-key or Natural-key?

久未见 提交于 2019-11-26 07:48:22
问题 Which one is the best practice and Why ? a) Type Table, Surrogate/Artificial Key Foreign key is from user.type to type.id : b) Type Table, Natural Key Foreign key is from user.type to type.typeName : 回答1: I believe that in practice, using a natural key is rarely the best option. I would probably go for the surrogate key approach as in your first example. The following are the main disadvantages of the natural key approach: You might have an incorrect type name, or you may simply want to