Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Composite primary keys
Message
From
01/12/2004 10:04:55
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
01/12/2004 09:42:02
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00966059
Message ID:
00966066
Views:
10
This message has been marked as the solution to the initial question of the thread.
>Hello,
>
>If I understood it correctly, the VFP database supports the use of a composite primary key only through function-based indexes. So if I take the following situation:
>
>Table A, key A_id (character)
>Table B, key B_id (auto-incremented integer)
>Table C establishing a m-n relationship between A and B, key (A_id,B_id)
>For C's primary key I have to create an index based on a function like A_id+TRIM(STR(B_id))
>
>That is probably what I will often have to do as I will have to add tables using auto-increments to an existing database which is using only character primary keys. It will certainly work. But now, It looks to me as I will be losing all benefits of using the more compact integer keys over the longer character keys. Is there a cleverer way to define a composite key ?

Instead of str(), you can also use bintoc().
a_id + bintoc(b_id)
that will only use 4 bytes for the numeric part.
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)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform