Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Suggestions for random candidate key generation methodol
Message
From
10/05/2004 23:14:26
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00902286
Message ID:
00902679
Views:
28
Hi, Gérald,


>Its 9,999,999 + 1 , Dont forget the '0000000' :)

Right. :)

>Its the 'random' part of the equation that ring a bell.
>
>10 millions seem to be a big number, but if you generate random numbers periodically, chances are relatively high that you generate the same number again. You have to check if the number exist each time you generate a new one.

This is where I like David and Sergey's suggestion so much--generate the keys first, and then discard them from a pool (or mark them used) as they are used.

>If you introduce a sequential part in your number, ie: derive a number from a date, you only have to check for replicate for the current day. For example you can use date()-date(2000,1,1) to get 4 digits that was unique for the current day. This let 3 digits (1000 numbers) for the current day.

I'd considered using part of the date embedded in the digit, but it doesn't really gain me much. Using the pool idea ahead is nice, though it does take some getting used to (for me) since I always think of creating records only when they're needed.
>

Thanks for your ideas, and I'm sure that readers will find it helpful, too.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform