Should we use GUID?

Should we use GUID?

You use it anywhere that you need an identifier that guaranteed to be different than every other. GUIDs are generally used when you will be defining an ID that must be different from an ID that someone else (outside of your control) will be defining. One such place in the Interface identifier on ActiveX controls.

How is a GUID created?

The general types of GUIDs are: Random: Just use the system’s random-number generator to create a 128-bit number. Time-based: Create a GUID based on the current time. Hardware-based: Make a GUID with certain portions based on hardware features, such as the MAC address of a network card.

What are the pros and cons of Guid?

GUID Pros Unique across every table, every database, every server Allows easy merging of records from different databases Allows easy distribution of databases across multiple servers You can generate IDs anywhere, instead of having to roundtrip to the database Most replication scenarios require GUID columns anyway

When to use a GUID instead of an ID?

GUID primary keys are a natural fit for many development scenarios, such as replication, or when you need to generate primary keys outside the database. But it’s still a question of balancing the tradeoffs between traditional 4-byte integer IDs and 16-byte GUIDs:

Which is better a Guid or an integer?

Using a GUID as a row identity value feels more natural– and certainly more truly unique– than a 32-bit integer. Database guru Joe Celko seems to agree. GUID primary keys are a natural fit for many development scenarios, such as replication, or when you need to generate primary keys outside the database.

Which is better primary key or GUID ID?

Database guru Joe Celko seems to agree. GUID primary keys are a natural fit for many development scenarios, such as replication, or when you need to generate primary keys outside the database. But it’s still a question of balancing the tradeoffs between traditional 4-byte integer IDs and 16-byte GUIDs: