Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Primary key
Message
From
18/03/2003 22:35:41
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
18/03/2003 22:22:49
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00766466
Message ID:
00767360
Views:
18
>Hi,
>Thank you for your info.
>My further question is,
>if I have a many-to-many relationship table, how should I build up the candicate index to ensure the uniqueness which contain 2 integer value?? Should I just add 2 integer or STR() them and join it as string?
>
>Thank you

Add 2 integers won't work: for instance, 2+3 is the same as 1+4.

You have several options, for instance:

  • str(Field1) + str(Field2)
  • Field1 * 1000000 + Field2 (assuming Field2 will not be larger than one million)
  • bintoc(Field1) + bintoc(Field2)

    The last option is the one I usually use in these cases. Both str() and bintoc() convert an integer to a character, but str() uses 10 bytes, and bintoc() only 4.

    Additional notes:

    (1) If you use collation sequences, turn them off for this index.
    (2) The result of bintoc() is not very readable for humans, but this should not be a problem if you only want to ensure uniqueness.

    HTH,

    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)
  • Previous
    Next
    Reply
    Map
    View

    Click here to load this message in the networking platform