[SQL] Re: Using Random Sequence as Key

2001-04-26 Thread Vasilis Samoladas
Hello Bernardo, there is a somewhat mathematical solution to your problem. You can use a unique key, say 0<= k < MAX for each record, and a second key which is computed from the first, say f(k), which will give you a unique permutation of the numbers 0,...,MAX-1. It will not be random, but it wil

Re: [SQL] Re: Using Random Sequence as Key

2001-04-17 Thread Brook Milligan
It is a good way to solve it but since I don't want/can't use cookies in my application I could use only the random key but it would have to be unique or the where key=$key could refer to multiple lines or I would have to ask for the user to input both the random and the serial number

Re: [SQL] Re: Using Random Sequence as Key

2001-04-17 Thread Josh Berkus
Bernardo, > I needed the random field because if I use serial and the user gets a > 34203 > he's sure that 34202 exists, and that (probably, there where 34202 > inserts > before him (or at least an offset + some)). Using a random just makes > the > user totally blind. > As I said I could use a se

[SQL] Re: Using Random Sequence as Key

2001-04-16 Thread Bernardo de Barros Franco
It is a good way to solve it but since I don't want/can't use cookies in my application I could use only the random key but it would have to be unique or the where key=$key could refer to multiple lines or I would have to ask for the user to input both the random and the serial number wich wouldn'

[SQL] Re: Using Random Sequence as Key

2001-04-16 Thread Bernardo de Barros Franco
Since I can't really redesign my application, I could index the table using a serial but still would need a field with the random and unique number. I tried using including a unique in : create table test (id int UNIQUE default random() * 8 + 1, content text); and it didn't return any erro