List:General Discussion« Previous MessageNext Message »
From:Michael Satterwhite Date:January 21 2011 6:14pm
Subject:Re: best way to have a unique key
View as plain text  
On Friday, January 21, 2011 09:23:47 am Jerry Schwartz wrote:

> 
> [JS] A UUID (what Microsoft calls a GUID) is based in part on the MAC
> address of the generating device. Since MAC addresses are supposed to be
> unique across the known universe, so should a UUID.
> 

Not entirely true - and even when true your conclusion doesn't follow.

I'll be the first to admit that we are straining at gnats, here. Generating a 
UUID does not require a machine to have an Ethernet card. The presence of a 
Mac address is, therefore, not guaranteed. Even if the machine does have an 
ethernet card, the definition of the UUID suggests - but does not require - 
that it be used (I believe this is discussed in another reply). Even if it is 
used, there are still a (admittedly large) portion of it that is created by a 
random number generation. Assuming a reasonably good generator, it is still 
possible for a collision on a single machine. 

The question then becomes, how much of a problem is that? The odds are that 
I'll be LONG gone before that happens. But it could happen tomorrow. If it's 
just a matter of "Oops, lets do a rollback and go again", who cares? If it's a 
life sustaining mission critical problem where an atomic war starts if the 
transaction fails ... you might want to at least think about another key. 
Personally, I wouldn't lose sleep over it.

Another reasonable - and faster - source of a unique key would be to have a 
human set unique server id on each machine generating the key. In that case a 
two field primary key with the first being the server id and the second part 
being an auto_increment field should guarantee a unique key - at least until it 
wraps around. This, of course, assumes that the administrator that sets up the 
servers doesn't make a mistake with setting the server id. Which brings up the 
"how much of a problem would that be" question again.

Bottom line ... exactly how paranoid are you?

---Michael
Thread
best way to have a unique keyAnthony Pace20 Jan
  • Re: best way to have a unique keyKrishna Chandra Prajapati20 Jan
    • Re: best way to have a unique keyAnthony Pace20 Jan
      • Re: best way to have a unique keyLuciano Furtado20 Jan
    • RE: best way to have a unique keyDaevid Vincent20 Jan
Re: best way to have a unique keyAnthony Pace20 Jan
  • Re: best way to have a unique keyAnthony Pace20 Jan
    • Re: best way to have a unique keyMichael Dykman20 Jan
  • Re: best way to have a unique keyJohan De Meersman21 Jan
    • RE: best way to have a unique keyJerry Schwartz21 Jan
      • Re: best way to have a unique keyMichael Satterwhite21 Jan
    • Re: best way to have a unique keyMichael Dykman21 Jan
      • RE: best way to have a unique keyJerry Schwartz21 Jan