What is a GUID? Why and where should I use it?

What is a GUID? Why and where should I use it?
I have seen GUID links in many places and on Wikipedia, but it’s not very clear where you can use it. If someone could answer that, it would be nice. Thanks

+55
language-agnostic guid
Dec 16 '08 at 16:07
source share
15 answers

A GUID technically stands for a globally unique identifier. This is actually a 128-bit structure that is unlikely to ever repeat or create a collision. If you are doing math, the range of values ​​is in undecillions .

Use hints if you have several independent systems or clients generating an identifier that must be unique.

For example, if I have 5 client applications that create and insert transactional data in a table with a unique identifier restriction, then use the hints. This prevents forcing the client to first request the issued identifier from the server.

This is also great for factory objects and systems that have many types of objects stored in different tables, where you do not want any 2 objects to have the same identifier. This greatly simplifies the implementation of caching and flushing schemes.

+77
Dec 16 '08 at 16:14
source share

A GUID is a globally unique identifier. You use it wherever you need an identifier that is guaranteed to be different from any other.

Usually you want the value to be “locally unique” —the primary key identifier in the database table, for example, may differ only from the other rows in this table, but it can be the same as the identifier in other tables. (no GUID needed here)

GUIDs are commonly used when you define an identifier that should be different from an identifier that someone else will define (out of your control). One such place in the interface identifier for ActiveX controls. Anyone can create ActiveX, and not know with what other control someone will use them - and nothing prevents everyone from giving their controls the same name. GUIDs save them distinctly.

A GUID is a combination of time (in very small fractions of a second) (therefore, it ensures that it is different from any GUID determined before or later) and a number that identifies your location (sometimes taken from the MAC address of the network card) (therefore, it is sure , which is different from any other GUID defined right now by someone else).

They are also sometimes called UUIDs (Universal Unique Identifiers).

+17
Dec 16 '08 at 16:11
source share

In addition to all the other answers, here is the online GUID generator:

http://www.guidgenerator.com/

What is a GUID?

A GUID (or UUID) is an acronym for “Globally Unique Identifier” (or “Universal Unique Identifier”). This is a 128-bit integer used to identify resources. The term GUID is commonly used by developers working with Microsoft technologies, while the UUID is used everywhere.

How unique is a GUID?

128 bits is large enough, and the generation algorithm is unique enough that if 1,000,000,000 GUIDs are second, within 1 year the probability of duplication will be only 50%. Or if every person on Earth created 600,000,000 GUIDs, there will only be a 50% chance of duplicating.

How are GUIDs used?

GUIDs are used in software development as database keys, component identifiers, or anywhere else a truly unique identifier is required. GUIDs are also used to identify all interfaces and objects in COM programming.

+13
Dec 16 '08 at 16:22
source share

GUID is the "Global Unique Identifier". Also called UUID (Universal Unique Identifier).

This is basically a 128-bit number that is generated in some way (see RFC 4112 http://www.ietf.org/rfc/rfc4122.txt ), which makes duplication almost impossible to be generated. That way, I can generate GUIDs without any third party organization that needs to provide them to me so that they are unique.

One widespread use of GUIDs is identifiers for COM objects on Windows (classes, typelibs, interfaces, etc.). Using a GUID, developers can create their own COM components without contacting Microsoft to get a unique identifier. Although the identification of COM objects is the main use of GUIDs, they are used for many things that need unique identifiers. Some developers will generate GUIDs for records in the database to provide them with an identifier that can be used even if they must be unique in many different databases.

Typically, you can think of a GUID as a serial number that can be generated by anyone at any time, and they will know that the serial number will be unique.

Other methods for obtaining unique identifiers include obtaining a domain name. To ensure that domain names are unique, you must obtain them from an organization (ultimately managed by ICANN).

Because GUIDs can be cumbersome (from a human readable point of view, this is a string of hexadecimal numbers, usually grouped like this: aaaaaaaa-bbbb-cccc-dddd-ffffffffffff), some namespaces that need unique names in different organizations have a different scheme (often based on domain names Internet).

Thus, the namespace for Java packages by convention begins with the domain name orgnaization (reverse), followed by names that are defined in a specific organizational way. For example, a Java package might be called:

com.example.jpackage 

This means that liability for name collisions becomes the responsibility of each organization.

XML namespaces also become unique in a similar way - by convention, someone creating an XML namespace must make it "under" a registered domain name under their control. For example:

 xmlns="http://www.w3.org/1999/xhtml" 

Another way to manage unique identifiers is through the Ethernet MAC address. The company that makes the Ethernet cards should get a block of addresses assigned to them by IEEE (I think this is IEEE). In this case, the scheme works very well, and even if the manufacturer screws up and issues cards with duplicate MAC addresses, everything will work fine until these cards are on the same subnet, since only the IP address is used to route packets outside the subnet. Although there are some other uses of MAC addresses that may be affected - one of the GUID generation algorithms uses the MAC address as one parameter. This method of generating GUIDs is not so widely used because it is considered a privacy risk.

One example of a unique identifier scheme that didn’t work very well was the Microsoft ID provided for VxD drivers in Windows 9x. Third-party VxD driver developers should have asked Microsoft to provide a set of identifiers for any drivers that a third-party developer wrote. In this way, Microsoft can guarantee that duplicate identifiers are not duplicated. Unfortunately, many driver authors never bothered and simply used any identifier in the VxD example that they used as a starting point. I’m not sure how many problems this caused - I don’t think the uniqueness of the VxD ID was absolutely necessary, but it probably affected some functions in some APIs.

+10
Dec 16 '08 at 16:41
source share

GUID or UUID (globally and universally). Unique identifier is a unique identifier. When you need something truly unique, there are libraries that can help you.

See the GUID on wikipedia for more details.

As for when you do not need a GUID, this is when the counter that you control (in one way or another, like a SERIAL SQL type or sequence) is incremented. Indexing a “text” value (GUID in text form) or a 128-bit binary value (which is a GUID) is much more expensive than an integer.

+9
Dec 16 '08 at 16:11
source share

Someone said that they are conceptually 128-bit random values, and this is essentially true, but read a bit on UUIDs (usually the GUID refers to the Microsoft UUID implementation), I see that there are several different versions of UUIDs, and most of them on not really random. Thus, you can create a UUID for the machine (or something else) and be able to reliably repeat this process to get the same UUID along the way, which is important for some applications.

+5
Dec 16 '08 at 16:46
source share

It’s easier for me to think of them as simply “128-bit random values.” This, in essence, is what they are. There are several algorithms for including part of the information in a few digits of your GUID (so the random part gets a little smaller), but still they are quite large almost random values.

Because they are so large, it is extremely unlikely that two GUIDs will ever be created the same. For all practical purposes, every GUID ever created is unique in the world.

I will leave this to you to figure out where to use them, but the other answers already have a few examples. Let your imagination burst. :)

+4
Dec 16 '08 at 16:22
source share

It can be difficult to understand, because all the mathematicians who go after their creation. Think of it as a unique identifier. You can get Visual Studio to generate one for you or .NET if you use C # or one of many other applications or websites. They are considered unique, because there is such a silly little chance that you will see the same thing that is not worth considering.

+3
Dec 16 '08 at 16:15
source share

128-bit globally unique identifier. You can generate a GUID from now until sunset, and you will never generate the same GUID twice, and no other will. They are used a lot with COM.

Like, for example, for something that you used them for, we use them in one of our products. Our users can create categories and maps on different devices. We want to make sure that we do not confuse the category created on one device with the category created on another, so it is important that the identifiers are unique no matter who generates them, where they generate them and when they generate them. Thus, we use the GUID (in fact, we use our own scheme using 64-bit numbers, but they are similar to the GUID).

+3
Dec 16 '08 at 16:16
source share

GUID = globally unique identifier.

Use it when you want to uniquely identify something in a global context.

This generator can be convenient.

+2
Dec 16 '08 at 16:11
source share

GUID means “globally unique identifier” and you use it, if you want, erm, a globally unique identifier.

In RSS feeds, for example, you must have a GUID for each item in the feed. In this way, the feed reader can track whether you have read this item or not. Without a GUID, it would be impossible to say.

A GUID differs from something like a database identifier in that no matter who creates the object — you, me, the guy down the street — our GUIDs will always be different. There should be no collisions using the GUID.

You will also see the term UUID, which means "Universal Unique Identifier". There is no difference between them. UUID is a more suitable term. GUID is a term used by Microsoft.

+2
16 Dec '08 at 16:16
source share

If you need to create an identifier that must be unique throughout the life of your application, you use a GUID.

Imagine that you have a server with sessions, if you give each session a GUID, you are sure that it will be unique for every session ever created by your server. This is useful for tracking bugs.

+2
Dec 16 '08 at 16:16
source share

One of the particularly useful GUID applications that I have found is to use them to track unique visitors in webapps where visitors are anonymous (i.e. not logged in or not registered).

+2
Dec 16 '08 at 16:19
source share

A few years ago, I worked on an ACD call center system, where we wanted to collect call details records from several call processors into a single database. I set the column in MS SQL to generate a GUID for the database key, and not use the system serial identifier (identification column). Then it was required to set the default value for NewID (or to generate it in the code, but the function NewID () was more secure). Of course, having a large value for the key can cause a few eyebrows, but I would rather give up space than the risk of a collision.

I did not see anyone accessing using the GUID as the database key, so I thought this could help to find out that you can do this too.

+2
Dec 19 '08 at 23:59
source share

The Wikipedia article on GUIDs is pretty straightforward about what they are used for - perhaps rephrasing your question will help - what do you need a GUID for?

+1
Dec 16 '08 at 16:12
source share



All Articles