Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Primary key
Message
From
19/10/2007 14:03:46
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
19/10/2007 13:53:29
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01261997
Message ID:
01262250
Views:
24
>I see Hilmar has given you a lot of information. Just as an aside, you should never ever get a duplicate primary key. A primary key should be a surrogate key in that it has no business meaning and so the system should be generating the keys for you (whether your own generation code or an Autoinc field).

I like to program this way too, but opinions seem to be quite divided on this issue. My article on PKs shows how to assign a sequential primary key. VFP 9 has the auto-incremental field, but I would probably prefer to continue using my own SerialNumber() (we are still using VFP 6, sigh).

I should add that with sequential numbers as primary keys. the primary key will never have duplicates. But the candidate keys can very well have duplicates, and VFP checks among deleted records. So - when using this design philosophy - a candidate index should be filtered on not deleted(). Thus, the user can delete a record and re-create a record with the same PK.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform