Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Primary key
Message
De
18/03/2003 22:35:41
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
18/03/2003 22:22:49
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:
00767360
Vues:
14
>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)
  • Précédent
    Suivant
    Répondre
    Fil
    Voir

    Click here to load this message in the networking platform