Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Primary key
Message
De
21/03/2003 09:21:18
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
20/03/2003 23:29:22
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:
00768545
Vues:
22
>Hi,
>Could you please give me some ideas about PK for invoicesno, salesno...
>If I need prefix for these .. then how? Should I have another table for these purpose?
>
>Thank you

Are you asking about the naming convention? My personal naming convention is to call the PK (and the FK in other tables) the same as the table.

Table: Article
PK: Article
FK in other tables: Article

I had considered adding "ID" to each PK, but then, the field names will often be too long. (Field names can have up to 127 characters; the problem is with the index, which is restricted to 10 characters.)

Actually, in the example above, I had really changed the tablename to ArticleMain. The reason is a bug in the RI Builder. If I have a table called "Article", another table called "Supplier", and a third table "ArticleSupplier" (what articles can each supplier provide), the RI-Builder can get confused between "Supplier" and "ArticleSupplier", since "Supplier" is at the end of "ArticleSupplier" (it might check in the wrong table).

AFAIK, this bug hasn't been solved yet. Therefore, to avoid trouble, instead of "Article" I use "ArticleMain", and instead of "Supplier", I use "SupplierMain". In this case, the PK doesn't include the "Main" part:

Table: ArticleMain
PK: Article
FK in other tables: Article


You can use other naming conventions, of course. The most important point is that you should try to be consistent. That is, don't use one rule for one table, and a completely different rule for another table.

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