Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Primary and Candidate
Message
De
02/08/2001 10:39:15
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
02/08/2001 10:33:31
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00538812
Message ID:
00538816
Vues:
12
>Hi all
>Can anyone clear up the difference between primary and candidate indexes?
>
>Thanks.

Both forbid you to make duplicate values. For practical purposes (in Visual FoxPro), you can use them interchangebly - in theory.

However, the primary key is supposed to be the "principal way" to identify an individual record. Particularly, if a certain field (or fields) are the primary key in one table, you would use the same value(s) as foreign key in other tables.

To keep things well organized, then, you should decide what field(s) you want to use to reference a record in other tables. This should be your primary key.

Use candidate for additional fields that have to be unique.

I use primary keys without business value in most tables - autogenerated, so to speak. (Autogenerated with a function, called form default value of field. Sequence is stored in a table.) The end-user will usually not see these values.

This is my primary key, and this I use as foreign key in other table. That is, I create permanent relationships according to this key.

But often, I also need the code that the user sees (e.g., client code) to be unique. For this, I use a candidate index.

HTH, Hilmar.
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform