473,322 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Is a GUID always unique?

Greetings All, I have read many upon many articles here regarding GUID
data types and uniqueness. There have been many opinions regarding
the effectiveness of GUID's and when they should/should not be used.
However, every article strongly implies, if it does not state it
outright, that GUID's are always unique. My question is this, what
happens if you have a database that uses GUID's and the NIC is changed
out on the box? From what I understand the MAC address of the NIC is
used as part of the algorithm to generate a GUID. If you change out
the NIC after generating 1 billion GUID's do you run the chance of
generating a duplicate GUID?

I look forward to your insightfulness on this issue.

Regards, Louis.
Jul 20 '05 #1
4 15598
"Louis Frolio" :
Greetings All, I have read many upon many articles here regarding GUID
data types and uniqueness. There have been many opinions regarding
the effectiveness of GUID's and when they should/should not be used.
However, every article strongly implies, if it does not state it
outright, that GUID's are always unique. My question is this, what
happens if you have a database that uses GUID's and the NIC is changed
out on the box? From what I understand the MAC address of the NIC is
used as part of the algorithm to generate a GUID. If you change out
the NIC after generating 1 billion GUID's do you run the chance of
generating a duplicate GUID?

I look forward to your insightfulness on this issue.

Regards, Louis.


Louis,

Assuming the RPC and COM implementation for GUID creation on Windows (and I
assume that's what SQL Server uses as well, but I'm not sure), then a GUID
is virtually guaranteed to be unique even if you switch MAC addresses (by
switching cards or changing it in software if the network card supports that
feature). Computers without network cards are guaranteed to generate unique
GUID on that computer but in practice are still pretty good at generating
completely unique GUID's.

I think you'll find that most articles (especially those written by people
with training in Computer Science or Software Engineering) will skirt the
issue because I don't think there's an algorithm that can formally guarantee
universal unqiueness. (If there is someone *please* correct me: I'd love to
know what it is!)

But... keep in mind that a GUID is 128 bits. If you assume that 64 bits
will be used as a system identifier (like a MAC address), you would still
need more than a quadrillion GUID's before you started approaching the realm
of likely duplication. For some really crazy numbers: assume 1,000,000
computers generating a 1,000,000 GUID's a day. In a thousand years, you
would have used up around 2% of the "number space" in 64 bits. (Of course,
this is a specious example since we conveniently ignored the algorithmic
difficulty of "divying up" the range of numbers possible in 64 bits, but
it's still a cool number :)

That's why GUID's really shine in distributed environments: any computer can
generate as many unique identifiers as required. We use them for a system
we have where a client must create an "entity" that when mapped to our
relational schema could be hundreds of rows across multiple tables. And for
reasons I won't go into, the client must be able to reliably create the
entire entity before ever connecting to a server. Without GUID's (or
something similar) we'd need to something much more painful which would
probably end emulating the MS GUID algorithm anyway.

The point of the above? After millions of these "entities" and hundreds
(possibly thousands) of GUID's for COM components, we've never had a
collision. And that includes computers that have changed Ethernet cards 3
or 4 times, computers that were operated with no network adapter installed
for a week at a time, and computers with multiple adapters. And in our
initial testing for the system 3 or so years ago, we generated 500 million
GUIDS from a single computer and never had a collision.

The bottom line and my $0.02? If you decide to go with GUID's, of course
use constraints in the database like you would for any other column that is
supposed to be unique or a foreign key or whatever, but if an error is ever
detected, look for software bugs waayyyyyy before suspecting duplicate GUID
creation.

Craig
Jul 20 '05 #2
Louis Frolio (fr*****@yahoo.com) writes:
Greetings All, I have read many upon many articles here regarding GUID
data types and uniqueness. There have been many opinions regarding
the effectiveness of GUID's and when they should/should not be used.
However, every article strongly implies, if it does not state it
outright, that GUID's are always unique. My question is this, what
happens if you have a database that uses GUID's and the NIC is changed
out on the box? From what I understand the MAC address of the NIC is
used as part of the algorithm to generate a GUID. If you change out
the NIC after generating 1 billion GUID's do you run the chance of
generating a duplicate GUID?


The MAC address thing only concerns NT4. On Win2000 and later it is
completely random.

And 1 billion is a whole lot. Even if you would happen to mean 1
milliard it is a whole lot. Even if you get 100000 orders a day, it
takes 27 years before you have a milliard of them. For a billion
orders that's 27000 years...

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3
"Craig Kelly" <cn************@nospam.net> wrote in message news:<Sh*********************@bgtnsc05-news.ops.worldnet.att.net>...
"Louis Frolio" :
Greetings All, I have read many upon many articles here regarding GUID
data types and uniqueness. There have been many opinions regarding
the effectiveness of GUID's and when they should/should not be used.
However, every article strongly implies, if it does not state it
outright, that GUID's are always unique. My question is this, what
happens if you have a database that uses GUID's and the NIC is changed
out on the box? From what I understand the MAC address of the NIC is
used as part of the algorithm to generate a GUID. If you change out
the NIC after generating 1 billion GUID's do you run the chance of
generating a duplicate GUID?

I look forward to your insightfulness on this issue.

Regards, Louis.


Louis,

Assuming the RPC and COM implementation for GUID creation on Windows (and I
assume that's what SQL Server uses as well, but I'm not sure), then a GUID
is virtually guaranteed to be unique even if you switch MAC addresses (by
switching cards or changing it in software if the network card supports that
feature). Computers without network cards are guaranteed to generate unique
GUID on that computer but in practice are still pretty good at generating
completely unique GUID's.

I think you'll find that most articles (especially those written by people
with training in Computer Science or Software Engineering) will skirt the
issue because I don't think there's an algorithm that can formally guarantee
universal unqiueness. (If there is someone *please* correct me: I'd love to
know what it is!)

But... keep in mind that a GUID is 128 bits. If you assume that 64 bits
will be used as a system identifier (like a MAC address), you would still
need more than a quadrillion GUID's before you started approaching the realm
of likely duplication. For some really crazy numbers: assume 1,000,000
computers generating a 1,000,000 GUID's a day. In a thousand years, you
would have used up around 2% of the "number space" in 64 bits. (Of course,
this is a specious example since we conveniently ignored the algorithmic
difficulty of "divying up" the range of numbers possible in 64 bits, but
it's still a cool number :)

That's why GUID's really shine in distributed environments: any computer can
generate as many unique identifiers as required. We use them for a system
we have where a client must create an "entity" that when mapped to our
relational schema could be hundreds of rows across multiple tables. And for
reasons I won't go into, the client must be able to reliably create the
entire entity before ever connecting to a server. Without GUID's (or
something similar) we'd need to something much more painful which would
probably end emulating the MS GUID algorithm anyway.

The point of the above? After millions of these "entities" and hundreds
(possibly thousands) of GUID's for COM components, we've never had a
collision. And that includes computers that have changed Ethernet cards 3
or 4 times, computers that were operated with no network adapter installed
for a week at a time, and computers with multiple adapters. And in our
initial testing for the system 3 or so years ago, we generated 500 million
GUIDS from a single computer and never had a collision.

The bottom line and my $0.02? If you decide to go with GUID's, of course
use constraints in the database like you would for any other column that is
supposed to be unique or a foreign key or whatever, but if an error is ever
detected, look for software bugs waayyyyyy before suspecting duplicate GUID
creation.

Craig

Thank You Craig.

Louis
Jul 20 '05 #4
Erland Sommarskog <es****@sommarskog.se> wrote in message news:<Xn**********************@127.0.0.1>...
Louis Frolio (fr*****@yahoo.com) writes:
Greetings All, I have read many upon many articles here regarding GUID
data types and uniqueness. There have been many opinions regarding
the effectiveness of GUID's and when they should/should not be used.
However, every article strongly implies, if it does not state it
outright, that GUID's are always unique. My question is this, what
happens if you have a database that uses GUID's and the NIC is changed
out on the box? From what I understand the MAC address of the NIC is
used as part of the algorithm to generate a GUID. If you change out
the NIC after generating 1 billion GUID's do you run the chance of
generating a duplicate GUID?


The MAC address thing only concerns NT4. On Win2000 and later it is
completely random.

And 1 billion is a whole lot. Even if you would happen to mean 1
milliard it is a whole lot. Even if you get 100000 orders a day, it
takes 27 years before you have a milliard of them. For a billion
orders that's 27000 years...

Thank You Erland.

Louis
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Joe Wong | last post by:
Hi, I need to implement a unique number generator that 1 or more processes on same or different machines will make use of it. Is there any library / project available already for this? Thanks...
2
by: Robert Oschler | last post by:
Anybody seen a Javascript function that would generate a fairly robust equivalent to the Windows GUID (Globally Unique Identifier)? thx Robert Oschler "Let the web hear you, add your...
2
by: Mullin | last post by:
I need to generate a unique no. in the format like yyyymmddxxxxxx (xxxxxx 6-digitl running number) I think of create a table with two columns date value 20050405 120 20050406 99...
1
by: hikums | last post by:
I am posting this here, just in case anyone may need this. Step 1: CREATE SEQUENCE ID_SEQ START WITH 1050000 INCREMENT BY 1 MAXVALUE 9999999 NO CYCLE NO CACHE ORDER
3
by: Kilroy Programmer | last post by:
Is there a way to store a unique numeric identifier (say, for example, an int) into a TreeNode, so that when the TreeNode is checked (since CheckBoxes is enabled) the eventhandler AfterCheck() can...
4
by: Alexander Muylaert | last post by:
Hi I need a unique key for an object. This key needs to be globally unique. A GUID serves my needs, but... Is somebody aware of a guid implementation that always returns a bigger GUID? The...
2
by: Chris Dunaway | last post by:
I have a web service which is accessed by a windows forms application. When the application submits a unit of work (a "job"), I want to return a job receipt or tracking number back to the...
15
by: Ashish Khandelwal | last post by:
As MSDN is not giving us guarantee upon uniqueness of Hash Code, so could any one suggest me that how to generate a unique Hash Code for same string always, and generate different-2 Hash Code...
2
by: Gary Hasler | last post by:
Does anyone have any suggestions on generating GUID (Globally Unique Identifier) tags with php? They would need to be in the format 4402bd8a-cd51-40ea-99d7-b510e89e344b Specifically this is for...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.