Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The easy way to form a primary key
Message
 
 
To
10/08/2001 16:05:03
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00541152
Message ID:
00542508
Views:
25
>Hi All,
>
>This is an interesting thread. Sorry for perhaps being naive :) but if the purpose of generating a primary key is to have an absolutely unique key for each record in a table then surely a quicker solution is to use a function which guarantees uniqueness *without* even needing to check if the key already exists. For example
>
>(local hard disk serial number) + Substr( Sys(2015), 3, 10 )
>
>The hard disk serial number guarantees uniqueness over a multiuser environment and, according to the VFP help, the sys(2015) generates unique strings within the same millisecond. Wouldnt this work?

Probably yes, but it would be a big character field. Also you should retrieve hard disk serial number, which is not a trivial task. Craig solution is much simpler, it works in multi-user environment and you use integer field, which is 4 bytes only.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform