Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Primary key
Message
De
19/10/2007 14:03:46
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
19/10/2007 13:53:29
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01261997
Message ID:
01262250
Vues:
25
>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)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform