Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Primary keys useless?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00047863
Message ID:
00048204
Vues:
20
>Hi Jim,
>
>Please could you explain me how u arrived the figure 2,000,000,000.
>
>For surrogate PK, I usually take the recc() and add 1 to it then, convert it
>to the base 36 and store. I do this by giving Default Value of PK as
>Base36( recc()+1 ). Where Base36 is an UDF which converts decimal to base 32.
>
>Is there a better way of doing this?
>
>TIA,
>Biju
Biju,

The Integer data type is a four byte singed binary number with a range of;

-2,147,483,647 to +2,147,483,646

If you make your PK an integer you can just give any new record the next number. If you restrict the values to positive only you get 2,147,483,646 unique positive numbers. If you start the sequence at -2,147,483,647 then you get over 4,000,000,000 unique values.

Integers need no conversion so you save on the time it takes to build your base 36 numbering system.

Keep in mind though, that if you use only positive numbers then you may run out of ids. If the system has 10 records added every second 24 hours a day it would only work for 24,855 days or approximately 68 years before it ran out of new values.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform