codeLover
codeLover

Reputation: 3810

Uniqueness of GUID

GUID is the 128bit unique identifier generated by MSFT.

I had a doubt if GUID is globally unique. I mean the GUID I generate, no one else in any system using any app in th eentire world can generate? IS that true?

I am surprised how will Microsoft know or keep track of this uniqueness.

And also the uniquie GUID generated can be linked to any entity ? Application, variable, system, ?

To what all entities can GUODs be linked to ? Can anyone kindly clarify on the concept of GUID ? Is it Programming language indepenent.

Upvotes: 2

Views: 621

Answers (5)

Luchian Grigore
Luchian Grigore

Reputation: 258618

I can think of one easy counter-example that proves GUID's aren't unique even on a single system, not to mention globally:

for i = 0 : 2^128
   generateGUID();

Indeed generating 2^128 GUID's is not feasible, but this demonstrates that uniqueness is mathematically impossible in a closed interval.

It's definitely very unlikely you'll ever encounter two identical GUIDs though.

Upvotes: 0

lx.
lx.

Reputation: 2317

These two articles might be of interest to you and should help you understand the concept behind those IDs.


The intent of UUIDs is to enable distributed systems to uniquely identify information without significant central coordination. [...] the word unique should be taken to mean "practically unique" rather than "guaranteed unique". [...] it is possible for two differing items to share the same identifier.

The identifier size and generation process need to be selected so as to make this sufficiently improbable in practice.

Anyone can create a UUID and use it to identify something with reasonable confidence that the same identifier will never be unintentionally created by anyone to identify something else. Information labeled with UUIDs can therefore be later combined into a single database without needing to resolve identifier (ID) conflicts.

Very simplistic: It is basically a method of creating an identifier (with a specific format) that has a very high probability of being unique.

Upvotes: 5

Aligus
Aligus

Reputation: 1605

It is possible to generate globally unique identifiers. For example, MAC address (which is unique) + current time. Of course, GUID generators use more complex algorithms.

Upvotes: 0

mloskot
mloskot

Reputation: 38912

You may want to read answers given to the very similar question Is a GUID unique 100% of the time? where the following quote from Wikipedia is included:

While each generated GUID is not guaranteed to be unique, the total number of unique keys (2^128 or 3.4×10^38) is so large that the probability of the same number being generated twice is very small. For example, consider the observable universe, which contains about 5×10^22 stars; every star could then have 6.8×10^15 universally unique GUIDs.

See links in the answer given by lx

Then, follow to the blog post by Raymond Chen GUIDs are globally unique, but substrings of GUIDs aren't for more details.

An interesting discussion followed another SO question Simple proof that GUID is not unique, worth checking too.

Upvotes: 0

littleadv
littleadv

Reputation: 20272

It is basically a kind of hash value of various bits of info, the total combination of which is highly likely to be unique or extremely rare. As with any hash, collisions are possible, the chances of them actually occurring are incredibly low and can be disregarded.

The hash function utilizes various pieces of information that are guaranteed or expected to be unique (for example, it can use the MAC address), or another option would be randomly generating the number (with 128 bits, chances of randomly generating exactly the same numbers are ... well, you can calculate, pretty low:-))

Upvotes: 1

Related Questions