Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Field to hold multiple references
Message
De
08/01/2001 07:15:28
Mark Hall
Independent Developer & Voip Specialist
Keston, Kent, Royaume Uni
 
 
À
08/01/2001 06:06:04
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00460487
Message ID:
00460508
Vues:
12
>I have a table that needs to hold up to 5 8-char references.
>
>I was thinking of creating a 40 character field, and hold the references in there, but is there a better way of doing this, should I use 5 fields perhaps?
>
>Thanks
>Kev

For my £0.02 worth,

If you have 'up to' five additional fields, you should use a related table (normalisation and all that) to hold one record for each of the possible alternate ids. Otherwise you'll end up doing:

SELECT * from MyTable WHERE cKey1 = lcKey or cKey2 = lcKey or cKey3 = lcKey or cKey4 = lcKey or cKey5 = lcKey

Then when you add another possible key, you'll need to change all your code to check cKey6 also.

INSTEAD you get:

Table - MyTable
nId
Other Fields

Table - MyKeys
nId
nMyTableId
cKey

SELECT MyTable.*
FROM MyKeys LEFT JOIN MyTable ON MyKeys.nTableId = MyTable.nId
WHERE MyKeys.cKey = lcKey
Regards
Mark

Microsoft VFP MCP
Menulib - OO Menus for VFP www.hidb.com/menulib
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform