List:General Discussion« Previous MessageNext Message »
From:Daevid Vincent Date:July 21 2011 7:13pm
Subject:RE: Next Unique Number - Generation
View as plain text  
I can think of several ways to accomplish this (or close to it).

 * Assign each server a number and prefix/append that number to the unique
ID.
 * initialize each table on each server at a different huge number so they
don't ever collide:
		ALTER TABLE `students` AUTO_INCREMENT=10000000;
	Other server:
		ALTER TABLE `students` AUTO_INCREMENT=20000000;
 * don't re-invent the wheel and just use UUID()
 * make the primary key a combination key of a regular auto-increment and
NOW() or RAND() or some other unique column of the table itself or something
like IP number of the server, etc.
 * setup a trigger to alter the primary key accordingly prior to insert.
Maybe one server is even numbers and the other is odd numbers, or use MOD()
or other math to have a pool of servers.
http://stackoverflow.com/questions/5416548/mysql-two-column-primary-key-with
-auto-increment


> -----Original Message-----
> From: Vikram A [mailto:vikkiatbipl@stripped]
> Sent: Wednesday, July 20, 2011 11:18 PM
> To: MY SQL Mailing list
> Subject: Next Unique Number - Generation
> 
> Hi there,
> 
> I need a technical help fro you,
> I have developed a software for college & school. Here we have concept
> called register number/admission number. These are two unique umber for
each
> student. My application resides Client/server model.
> These numbers will be generated (some defined format) to each student when
> they are admitted at first time. This admission process is taken place at
> different nodes at a time.
> In this scenario, I am facing difficulty that, the same number is
generated
> at time in two machines. (Logic is newest number will be displayed in the
> node before admission).
> 
> How can I stop this logical issue?
> Can i have solution for this?
> 
> Thank you in advance.

Thread
Next Unique Number - GenerationVikram A21 Jul
  • RE: Next Unique Number - GenerationDaevid Vincent21 Jul
    • Re: Next Unique Number - GenerationPrabhat Kumar22 Jul
Re: Next Unique Number - GenerationVikram A21 Jul