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.
  • D Dan Neely

    Nishant Sivakumar wrote:

    the current numbering system will provide us with enough new numbers for several generations into the future with no changes in the numbering system.

    About 2 generations or so. The last I heard they were expected to run out about the same time as the Y2039bug hits give or take demographic projection errors.

    -- You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer

    X Offline
    X Offline
    Xiangyang Liu
    wrote on last edited by
    #9

    dan neely wrote:

    About 2 generations or so.

    By that time, the government will probably have switched to GUID, and it will be tattooed in 10 different places on everyone's body. :)

    My .NET Business Application Framework My Home Page

    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?

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

      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

      V J R 3 Replies Last reply
      0
      • T Tarakeshwar Reddy

        :confused: What has this got to do with what Jith posted? You seem to prove that you are nothing more than a bot.

        V Offline
        V Offline
        Vikram A Punathambekar
        wrote on last edited by
        #11

        Don't you notice the change in language? He (It? :~)copy-pasted it from somewhere.

        Cheers, Vıkram.


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

        T 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

          V Offline
          V Offline
          Vikram A Punathambekar
          wrote on last edited by
          #12

          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 M S 3 Replies Last reply
          0
          • V Vikram A Punathambekar

            Don't you notice the change in language? He (It? :~)copy-pasted it from somewhere.

            Cheers, Vıkram.


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

            T Offline
            T Offline
            Tarakeshwar Reddy
            wrote on last edited by
            #13

            Yeah thats what I am trying to tell, why does he need to copy paste the information about social security number. It is the bots which do stuff like this and give irrelevant information. BTW he seems to have already changed his post:doh:, he has a different text now.

            1 Reply Last reply
            0
            • N Nish Nishant

              jith - iii wrote:

              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 after 50 years there is a possibility for the SSN being reassigned. Is it right?

              SSNs are not reused. See http://www.ssa.gov/history/hfaq.html Q20: Are Social Security numbers reused after a person dies? A: No. We do not reassign a Social Security number (SSN) after the number holder's death. Even though we have issued over 415 million SSNs so far, and we assign about 5 and one-half million new numbers a year, the current numbering system will provide us with enough new numbers for several generations into the future with no changes in the numbering system. There have been instances of accidental duplication though, and some instances of numbers getting invalidated due to their use in advertising.

              Regards, Nish


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

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

              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 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?

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

                Bad idea to use it. Here in Canada there are very strict laws against that kind of thing and probably in other jurisdictions as well. A good old GUID will never set you wrong.


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

                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

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

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

                  M 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
                    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