3 ms·
"In fact, even in RDBMS’s developers should be using a natural key as their primary key instead of an auto-incremented ID. " No, they shouldn't. The fact that
by outworlder 12y ago
"In fact, even in RDBMS’s developers should be using a natural key as their primary key instead of an auto-incremented ID. "
No, they shouldn't. The fact that your dataset may contain a piece of information that is usually unique its completely unrelated to the need of RDMSs to have identifiers to implement table relationships and to identify records in a table.
Not to mention that it can bring lots of headaches down the line. The classic example is using social security numbers (or another country's equivalent, such as CPF in Brazil) to identify individuals. Down the line you get a requirement to support international customers. That is now a major undertaking.
You are also offloading the responsibility of maintaining the uniqueness property to a third party, in effect trusting their database.
- eli 12y agoForget down the line, the US gov't makes mistakes -- anybody who has tried using SSN as a key can tell you there are multiple people with the same valid SSN. (And, of course, people who don't have one or who have a stolen or fake one)
- phkahler 12y agoThe noob never saw a person get married and change both their last name and email address. There is no such thing as a "natural key" that can never change, that's why auto-incrementing integers are used. Also, users should not rely on the keys being monotonic.