Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Field to hold multiple references
Message
From
08/01/2001 07:15:28
Mark Hall
Independent Developer & Voip Specialist
Keston, Kent, United Kingdom
 
 
To
08/01/2001 06:06:04
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00460487
Message ID:
00460508
Views:
10
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform