in reply to RE: RE: Random number
in thread Random number
As a matter of fact, I can, but I should warn you this can turn into an essay very quickly. :)
| South Park | VW Bug |
| Pinky & The Brain | Porsche 911 |
| X-Files | 72' Land Rover |
| The Daily Show | Cowboy Neal |
I've actually heard of people that use this sort of technique to memorize data for long periods of time, but for storing them in a database, it really doesn't seem to be very effective. (And on a side note, that isn't being random either) If you have hundreds of thousands of records, I bet you you'll start getting duplicate favorite shows, and even if you didn't, it would be hard as hell to tell what the car you had counted was in the 1st place.
| 1 | VW Bug |
| 2 | Porsche 911 |
| 3 | 72' Land Rover |
| 4 | Cowboy Neal |
The second method, which I use most frequently is a combination of time and process ID. The combination of both will give me unique data and two bits of information that are much more useful than the order of which they were entered into the database. Consider that the string being generated is "$^T$$". Every time we generate a new record, we have the epoch ($^T) and the current PID ($$) of when that record was created. Even if you have multiple records coming into the database, they can't be running under the same process ID, and therefor must be unique. (I have yet to see a machine that can spawn that many processes per second). And for examples sake, our table would look something like this (under my Win NT box):
| 963198426-505 | VW Bug |
| 963198679-503 | Porsche 911 |
| 963198688-505 | 72' Land Rover |
| 963198703-500 | Cowboy Neal |
#!/home/bbq/bin/perl
# Trust no1!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE(3): Random number - A very long reply...
by PipTigger (Hermit) on Jul 10, 2000 at 09:23 UTC | |
by BBQ (Curate) on Jul 10, 2000 at 10:03 UTC |