Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. choosing primary key

choosing primary key

Scheduled Pinned Locked Moved The Lounge
securityquestionlounge
28 Posts 16 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Vikram A Punathambekar

    So you fall into the "PKs should only be GUIDs" camp?

    Cheers, Vıkram.


    Déjà moo - The feeling that you've seen this bull before. Join the CP group at NationStates. Password: byalmightybob

    M Offline
    M Offline
    Marc Clifton
    wrote on last edited by
    #17

    Vikram A Punathambekar wrote:

    So you fall into the "PKs should only be GUIDs" camp?

    Absolutely. :) Marc

    Thyme In The Country
    Interacx

    People are just notoriously impossible. --DavidCrow
    There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer
    People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith

    1 Reply Last reply
    0
    • J jith iii

      Ok..then what is your opinion, can it be used as a unique key.

      M Offline
      M Offline
      Marc Clifton
      wrote on last edited by
      #18

      jith - iii wrote:

      Ok..but can it be used as a unique key.

      Ah, for indexing? That I don't know. Marc

      Thyme In The Country
      Interacx

      People are just notoriously impossible. --DavidCrow
      There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer
      People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith

      J 1 Reply Last reply
      0
      • V Vikram A Punathambekar

        So you fall into the "PKs should only be GUIDs" camp?

        Cheers, Vıkram.


        Déjà moo - The feeling that you've seen this bull before. Join the CP group at NationStates. Password: byalmightybob

        M Offline
        M Offline
        Member 96
        wrote on last edited by
        #19

        I've been doing db related business apps for...well forever and I've come to learn that it's a wise person who uses Guid's as primary keys. Besides all the uniqueness reasons and ease of combining databases etc it's a huge performance benefit because you can generate them at the client and do single trips to the db server for just about any operation.


        "110%" - it's the new 70%

        B 1 Reply Last reply
        0
        • J jith iii

          Ok.But I have read somewhere(could not get that article though I'm searching it for an hour) that in some cases like a missing identity or something like that the SSN may be reused. Like we may see more than one person with the same SSN in a 100 year period,if other guy had expired or missing long before.

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #20

          jith - iii wrote:

          Ok.But I have read somewhere(could not get that article though I'm searching it for an hour) that in some cases like a missing identity or something like that the SSN may be reused. Like we may see more than one person with the same SSN in a 100 year period,if other guy had expired or missing long before.

          That article was incorrect then. The site I linked to is the official govt website.

          Regards, Nish


          Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
          My latest book : C++/CLI in Action / Amazon.com link

          1 Reply Last reply
          0
          • V Vikram A Punathambekar

            So you fall into the "PKs should only be GUIDs" camp?

            Cheers, Vıkram.


            Déjà moo - The feeling that you've seen this bull before. Join the CP group at NationStates. Password: byalmightybob

            S Offline
            S Offline
            Sathesh Sakthivel
            wrote on last edited by
            #21

            Vikram A Punathambekar wrote:

            "PKs should only be GUIDs"

            Yes.

            Regards, Satips.

            1 Reply Last reply
            0
            • J jith iii

              Some where I read that SSN(social security number) can not be considered as primary key in complex applications. I also heard that if a person died now,after say 50 years there is a possibility for the SSN being reassigned. Is it right?

              L Offline
              L Offline
              leckey 0
              wrote on last edited by
              #22

              Strangely though they change your SSN after you die.

              __________________ Bob is my homeboy.

              1 Reply Last reply
              0
              • M Marc Clifton

                jith - iii wrote:

                Ok..but can it be used as a unique key.

                Ah, for indexing? That I don't know. Marc

                Thyme In The Country
                Interacx

                People are just notoriously impossible. --DavidCrow
                There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer
                People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith

                J Offline
                J Offline
                jith iii
                wrote on last edited by
                #23

                Not only for indexing.I mean if I have a column SSN which is not the primary key and I use GUID(Though no one here dare to follow it) as primary key,would that be a wrong decision if I set unique constraint for SSN.

                B 1 Reply Last reply
                0
                • J jith iii

                  Some where I read that SSN(social security number) can not be considered as primary key in complex applications. I also heard that if a person died now,after say 50 years there is a possibility for the SSN being reassigned. Is it right?

                  J Offline
                  J Offline
                  jetwash
                  wrote on last edited by
                  #24

                  Aside from the duplication issue, it would probably be a poor choice of primary key for a couple of other reasons. First, A person could decline to give you their SSN because of privacy or fraud concerns. If this were the case, you would have to generate a key value that does not duplicate any of the possible SSNs. The process for doing so would almost certainly be more complex than just generating a unique key up front. Second, by using SSN as a primary key, you introduce privacy requirements into your schema and processing. You would have to make sure that some output does not accidently expose the SSN to unauthorized recipients either explicitly or accidently, e.g. as part of some network communication. I would think that using SSN as a primary key would be more trouble than it is worth.

                  B 1 Reply Last reply
                  0
                  • M Marc Clifton

                    A primary key should never represent any real value like a SSN. Marc

                    Thyme In The Country
                    Interacx

                    People are just notoriously impossible. --DavidCrow
                    There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer
                    People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith

                    R Offline
                    R Offline
                    Rocky Moore
                    wrote on last edited by
                    #25

                    It was not that long ago, database purists said keys should "only" be real values and not just numbers or other forms of non-revelant data :)

                    Rocky <>< Latest Code Blog Post: SilverlightCity blog running! Latest Tech Blog Post: 15 Free utilites!

                    1 Reply Last reply
                    0
                    • M Member 96

                      I've been doing db related business apps for...well forever and I've come to learn that it's a wise person who uses Guid's as primary keys. Besides all the uniqueness reasons and ease of combining databases etc it's a huge performance benefit because you can generate them at the client and do single trips to the db server for just about any operation.


                      "110%" - it's the new 70%

                      B Offline
                      B Offline
                      Brady Kelly
                      wrote on last edited by
                      #26

                      Not to mention testing scenarios. I have had so many where I need to generate multitudes of new numbers, and with GUID's I really felt the lack of ID 'collisions' tangibly.

                      1 Reply Last reply
                      0
                      • J jith iii

                        Not only for indexing.I mean if I have a column SSN which is not the primary key and I use GUID(Though no one here dare to follow it) as primary key,would that be a wrong decision if I set unique constraint for SSN.

                        B Offline
                        B Offline
                        Brady Kelly
                        wrote on last edited by
                        #27

                        I would not have a problem. We use an Identity Number in South Africa. It's name describes it's very purpose, and I have often encountered these or used them as a unique constraint.

                        1 Reply Last reply
                        0
                        • J jetwash

                          Aside from the duplication issue, it would probably be a poor choice of primary key for a couple of other reasons. First, A person could decline to give you their SSN because of privacy or fraud concerns. If this were the case, you would have to generate a key value that does not duplicate any of the possible SSNs. The process for doing so would almost certainly be more complex than just generating a unique key up front. Second, by using SSN as a primary key, you introduce privacy requirements into your schema and processing. You would have to make sure that some output does not accidently expose the SSN to unauthorized recipients either explicitly or accidently, e.g. as part of some network communication. I would think that using SSN as a primary key would be more trouble than it is worth.

                          B Offline
                          B Offline
                          Brady Kelly
                          wrote on last edited by
                          #28

                          Another issue may be storing data on non-US citizens. You would probably have to use a passport number as a substitute.

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups