Using GUID as primary key in DB

G

Grey

I used .NET to generate a GUID for creating a new record in Access DB as primary key. Is it guaratee to be unique in the DB as the GUID is not generate in DB?? If so, is that mean GUID is generated based on machine instead of application, right??


Million Thanks
 
J

Joe Fallon

GUIDs are supposed to be globally unique.
Although it is theoretically possible to get a duplicate, it is extremely unlikely.
It should not matter where the GUID was generated.
--
Joe Fallon



I used .NET to generate a GUID for creating a new record in Access DB as primary key. Is it guaratee to be unique in the DB as the GUID is not generate in DB?? If so, is that mean GUID is generated based on machine instead of application, right??


Million Thanks
 
D

Darren Clark

I have one questoin... and i am not trying to start a flame or anythning..

But why would you use a GUID as the primary key? what is wrong with ints or numeric or things that sql knows how to index properly.

I used .NET to generate a GUID for creating a new record in Access DB as primary key. Is it guaratee to be unique in the DB as the GUID is not generate in DB?? If so, is that mean GUID is generated based on machine instead of application, right??


Million Thanks
 
S

Steve C. Orr [MVP, MCSD]

GUIDs keys are pretty common for situations where you need to merge similar data from multiple sources.
Imagine several identical systems running in parallel in separate parts of the country. Odds are you'll want to consolidate all that data to a central data warehouse eventually. When you merge them together, If all those databases were using numeric keys, now you've got duplicate keys. No good. If you used GUIDs for keys then you wouldn't have the problem.
There are other somewhat similar situations where GUID keys are useful too.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net



I have one questoin... and i am not trying to start a flame or anythning..

But why would you use a GUID as the primary key? what is wrong with ints or numeric or things that sql knows how to index properly.

I used .NET to generate a GUID for creating a new record in Access DB as primary key. Is it guaratee to be unique in the DB as the GUID is not generate in DB?? If so, is that mean GUID is generated based on machine instead of application, right??


Million Thanks
 
S

Steve C. Orr [MVP, MCSD]

Don't worry, you can rely on the GUIDs being unique.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


I used .NET to generate a GUID for creating a new record in Access DB as primary key. Is it guaratee to be unique in the DB as the GUID is not generate in DB?? If so, is that mean GUID is generated based on machine instead of application, right??


Million Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top