Using GUID as primary key in DB

Discussion in 'ASP .Net' started by Grey, May 7, 2004.

  1. Grey

    Grey Guest

    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
    Grey, May 7, 2004
    #1
    1. Advertising

  2. Grey

    Joe Fallon Guest

    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



    "Grey" <> wrote in message news:%...
    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
    Joe Fallon, May 7, 2004
    #2
    1. Advertising

  3. Grey

    Darren Clark Guest

    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.

    "Grey" <> wrote in message news:%...
    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
    Darren Clark, May 7, 2004
    #3
  4. 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


    "Darren Clark" <> wrote in message news:pDCmc.24648$...

    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.

    "Grey" <> wrote in message news:%...
    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
    Steve C. Orr [MVP, MCSD], May 7, 2004
    #4
  5. Don't worry, you can rely on the GUIDs being unique.

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


    "Grey" <> wrote in message news:%...
    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
    Steve C. Orr [MVP, MCSD], May 7, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sky
    Replies:
    2
    Views:
    437
  2. =?Utf-8?B?cG11ZA==?=
    Replies:
    1
    Views:
    596
    bruce barker
    Dec 28, 2004
  3. =?Utf-8?B?RGFuIFNpa29yc2t5?=

    GUID Primary Key In SqlDataSoure UpdateCommand Won't Work

    =?Utf-8?B?RGFuIFNpa29yc2t5?=, Aug 3, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    3,197
    =?Utf-8?B?RGFuIFNpa29yc2t5?=
    Aug 3, 2006
  4. Anon
    Replies:
    0
    Views:
    1,358
  5. Lionel
    Replies:
    9
    Views:
    3,370
Loading...

Share This Page