Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Uniqueness of Indexes - how do you handle this?
Message
From
07/07/2000 10:57:12
 
 
To
07/07/2000 03:33:18
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00376137
Message ID:
00389483
Views:
31
>Hi Kenneth,
>
>>Use a surrogate as a primary key (from a GetNextKey UDF for example) and you won't have to worry about duplicating deleted keys. Don't use natural key as a primary key although you will have to validate the the natural key to make sure that it is unique.
>
>In short, you're shifting the problem from the PK to the natural key. This is one of my objections about the argument: 'use generated PKs and don't worry about it again.'
>
>
>Walter,

Walter,

You are right. The problem is not eliminated but transfered to the validation of the natural key. But, I think this is correct. I don't think that the software package should be responsible for validating the correctness of a natural key (ie. assigning it as a primary key and thus must be unique in all cases). That should be handled in code (business rule?) which not only requires the programmer to think more about what the key actually represents but also allows for exceptions and modifications. Ernesto fell into the typical trap that us new programmers fall into: assuming that a key will always be unique but not foresee the case of deleting and then readding a record with the same key as the deleted record.

Ken

p.s. maybe this theory has been argued and debunked in this thread. I would love to see the different ideas. Unfortunatly I can't seem to get the entire thread. It always cuts off after two or three messages when I select all items to display and it is too long to click one by one.
Previous
Reply
Map
View

Click here to load this message in the networking platform