Click here to Skip to main content
15,895,462 members
Home / Discussions / Database
   

Database

 
GeneralRe: random unique number [mysql] Pin
PIEBALDconsult5-Dec-10 13:33
mvePIEBALDconsult5-Dec-10 13:33 
GeneralRe: random unique number [mysql] Pin
Eddy Vluggen5-Dec-10 20:32
professionalEddy Vluggen5-Dec-10 20:32 
GeneralRe: random unique number [mysql] Pin
PIEBALDconsult5-Dec-10 13:29
mvePIEBALDconsult5-Dec-10 13:29 
GeneralRe: random unique number [mysql] Pin
Luc Pattyn5-Dec-10 13:44
sitebuilderLuc Pattyn5-Dec-10 13:44 
AnswerRe: random unique number [mysql] Pin
dbaechtel8-Dec-10 4:51
professionaldbaechtel8-Dec-10 4:51 
AnswerRe: random unique number [mysql] Pin
Snowman588-Dec-10 7:08
Snowman588-Dec-10 7:08 
AnswerRe: random unique number [mysql] Pin
Pcube8-Dec-10 10:55
Pcube8-Dec-10 10:55 
AnswerRe: random unique number [mysql] Pin
AspDotNetDev8-Dec-10 18:57
protectorAspDotNetDev8-Dec-10 18:57 
Assuming you don't want to use a GUID...

Create a table of number ranges; call it RandRanges. These are the numbers that are not yet taken. Generate a random integer (use the Rand function along with some multiplication and addition) between 1 and the number of items in RandRanges. Use that number to select a row from RandRanges. Use the min/max values (i.e., the range) as the min/max of a random integer you will generate. Once you generate that integer, use that number as your desired random number. Then, modify the RandRanges table to take that value out. You can do that by deleting the row you just created and splitting it into two new ranges that you insert into the table.

For example, say RandRanges starts out with:
1: 1-100
2: 101-200

You then generate the random number 2, so you are gonna use the second item in RandRanges.
101-200

Now, you generate a random number between 101 and 200. Say that turns out to be 150. You would take that out of RandRanges:
1:1-100
2:101-149
3:151-200

You then use your unique random number, 150, however you like. This table will grow at about the same rate that you use the unique random numbers, so you don't have to worry too much about space considerations. In fact, the table will sometimes shrink. If you use up all the random numbers (not likely with an Int64 range), the table would become empty.

GeneralRe: random unique number [mysql] Pin
Member 40648389-Dec-10 22:28
Member 40648389-Dec-10 22:28 
GeneralRe: random unique number [mysql] Pin
AspDotNetDev11-Dec-10 16:34
protectorAspDotNetDev11-Dec-10 16:34 
Questionlist all databases / tables (mysql) Pin
Jassim Rahma5-Dec-10 3:08
Jassim Rahma5-Dec-10 3:08 
AnswerRe: list all databases / tables (mysql) Pin
PIEBALDconsult5-Dec-10 4:47
mvePIEBALDconsult5-Dec-10 4:47 
AnswerRe: list all databases / tables (mysql) Pin
Mycroft Holmes5-Dec-10 10:48
professionalMycroft Holmes5-Dec-10 10:48 
AnswerRe: list all databases / tables (mysql) Pin
Eddy Vluggen5-Dec-10 11:53
professionalEddy Vluggen5-Dec-10 11:53 
QuestionHow to add new object DataContext ? Pin
Yanshof4-Dec-10 23:21
Yanshof4-Dec-10 23:21 
AnswerRe: How to add new object DataContext ? Pin
PIEBALDconsult5-Dec-10 4:52
mvePIEBALDconsult5-Dec-10 4:52 
GeneralRe: How to add new object DataContext ? Pin
Yanshof5-Dec-10 5:23
Yanshof5-Dec-10 5:23 
GeneralRe: How to add new object DataContext ? Pin
PIEBALDconsult5-Dec-10 7:40
mvePIEBALDconsult5-Dec-10 7:40 
GeneralRe: How to add new object DataContext ? Pin
Not Active5-Dec-10 7:53
mentorNot Active5-Dec-10 7:53 
GeneralRe: How to add new object DataContext ? Pin
Yanshof5-Dec-10 8:56
Yanshof5-Dec-10 8:56 
GeneralRe: How to add new object DataContext ? Pin
Not Active5-Dec-10 9:31
mentorNot Active5-Dec-10 9:31 
GeneralRe: How to add new object DataContext ? Pin
Yanshof5-Dec-10 9:52
Yanshof5-Dec-10 9:52 
GeneralRe: How to add new object DataContext ? Pin
Not Active5-Dec-10 11:40
mentorNot Active5-Dec-10 11:40 
QuestionBest approach to DB Design where DB entity relates to many, many other DB entities Pin
G-Tek4-Dec-10 5:36
G-Tek4-Dec-10 5:36 
AnswerRe: Best approach to DB Design where DB entity relates to many, many other DB entities Pin
Dr.Walt Fair, PE4-Dec-10 11:09
professionalDr.Walt Fair, PE4-Dec-10 11:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.