Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Primary key
Message
De
19/03/2003 08:34:00
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
19/03/2003 08:20:07
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00766466
Message ID:
00767475
Vues:
22
>Hi,
>What about the auto-generated value? should I store it in Integer or character?
>
>Beside, should I just use the auto-generated value as forgeign key? For example in stock in table, should I place ItemCode ? Do you think place itemcode in stockin table will easier the error checking?
>
>Any comments?
>
>Thank you

My personal recommendation - many programmers use this method, and many others don't:

Use an integer, auto-generated, for the primary key of each table (or most tables). Don't show this key to the user.

If I call this the primary key, this implies that it is also used as foreign key in other tables.

For example, if you have a list of materials, each material will have a code which the user sees, and assigns - but according to the system I am recommending, this will not be the primary key. For the primary key, you will use an "auto-generated" integer, instead (before VFP 8, this would mean a separate table to store the sequences, a function to do the lookup, and call this function from the field's default value).

For other tables, use this same number as a foreign key. This might include the record of what materials come in and out, and the current stock (if you need to keep track of more than one warehouse).

Greetings,

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