- Local time
- Today, 13:01
- Joined
- Feb 28, 2001
- Messages
- 30,501
1. In the USA, some "natural" keys are limited as data keys due to considerations of the Privacy Act and the HIPAA laws. Using an autonumber can solve this problem, though the DMax + 1 and a couple of other schemes would certainly work well on "non-natural" keys.
We cannot ever forget that a database has a PURPOSE (else who would pay us for it?) and we have to abide by ancillary business rules governing said database. The autonumber key is just one way to comply with a business rule that says what natural candidates you CAN'T use as a key.
2. Using a visible autonumber is no biggie. Let me ask this: When you do on-line banking and you get a long confirmation number, do you have ANY DOUBT that this number can or does contain an autonumber or DMax+1 component? Showing the number key as some sort of confirmation number doesn't violate anything if you want that particular number to be invariant for the lifetime of your system. (What do you think your banker would do if you asked him to edit the validation number on a transaction?)
As has been mentioned before, the problem with natural keys in this situation is that while they can perhaps stay unique, they might not be immutable. This would add a (small) layer of complexity to your design if you HAD to use mutable natural keys and therefore had to allow for key changes. Using the synthetic keys? No biggie. Those who don't like synthetic keys are confusing pure theory with the requirements of a database in the real world.
By now has anyone guessed that I'm primarily a pragmatist who has even been known to occasionally {gasp} denormalize tables for specific types of efficiency when dealing with slow networks? But seriously, I don't think I care what is theoretically correct. What I want to know is what will work to make my DB better. Usually, that "work better" question is where the "theoretically correct" stuff comes into play, but if "theoretically correct" leaves me wiggle room, I will wiggle! I also endeavor to avoid letting the cart go before the horse by seeing what I need FIRST and THEN deciding what aspects of pure theory help me get there.
We cannot ever forget that a database has a PURPOSE (else who would pay us for it?) and we have to abide by ancillary business rules governing said database. The autonumber key is just one way to comply with a business rule that says what natural candidates you CAN'T use as a key.
2. Using a visible autonumber is no biggie. Let me ask this: When you do on-line banking and you get a long confirmation number, do you have ANY DOUBT that this number can or does contain an autonumber or DMax+1 component? Showing the number key as some sort of confirmation number doesn't violate anything if you want that particular number to be invariant for the lifetime of your system. (What do you think your banker would do if you asked him to edit the validation number on a transaction?)
As has been mentioned before, the problem with natural keys in this situation is that while they can perhaps stay unique, they might not be immutable. This would add a (small) layer of complexity to your design if you HAD to use mutable natural keys and therefore had to allow for key changes. Using the synthetic keys? No biggie. Those who don't like synthetic keys are confusing pure theory with the requirements of a database in the real world.
By now has anyone guessed that I'm primarily a pragmatist who has even been known to occasionally {gasp} denormalize tables for specific types of efficiency when dealing with slow networks? But seriously, I don't think I care what is theoretically correct. What I want to know is what will work to make my DB better. Usually, that "work better" question is where the "theoretically correct" stuff comes into play, but if "theoretically correct" leaves me wiggle room, I will wiggle! I also endeavor to avoid letting the cart go before the horse by seeing what I need FIRST and THEN deciding what aspects of pure theory help me get there.