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. Database & SysAdmin
  3. Database
  4. Best Praxis for “user-id/primary”

Best Praxis for “user-id/primary”

Scheduled Pinned Locked Moved Database
databasequestionsql-server
7 Posts 1 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hello experts I’m usually organizing the data internally using a “system” generated id (at the moment int generated by mssql sequences) to define primary keys and foreign key relations. That has sometimes advantages but on the other hand it is not really the clean way from the point of theory (and for data exchange it can be the real pain). Why? The user usually needs also to have his “user-id” which is the user’s primary… so with the way above I introduce an extra index. And basically the user primary should enough and should be used to define the db constraints. But programmers are lazy and like keys all of the same type…. Ok, long speech. What I’m really like asking for Best Praxis is: I’m at a point to migrate Interbase databases to MSSQL. Interbase has as default case sensitive indices while MSSQL has case insensitive as default. In case this “user-id” allows alphanumeric, what is better/best Praxis/usual: a.) Make Ids case sensitive ? b.) Make Ids case insensitive? Thank you in advance Bruno

    L 2 Replies Last reply
    0
    • L Lost User

      Hello experts I’m usually organizing the data internally using a “system” generated id (at the moment int generated by mssql sequences) to define primary keys and foreign key relations. That has sometimes advantages but on the other hand it is not really the clean way from the point of theory (and for data exchange it can be the real pain). Why? The user usually needs also to have his “user-id” which is the user’s primary… so with the way above I introduce an extra index. And basically the user primary should enough and should be used to define the db constraints. But programmers are lazy and like keys all of the same type…. Ok, long speech. What I’m really like asking for Best Praxis is: I’m at a point to migrate Interbase databases to MSSQL. Interbase has as default case sensitive indices while MSSQL has case insensitive as default. In case this “user-id” allows alphanumeric, what is better/best Praxis/usual: a.) Make Ids case sensitive ? b.) Make Ids case insensitive? Thank you in advance Bruno

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Since you can do "like" and "sounds like" searches in SQL Server, you need to review your "requirements" more. For the record, the recommended approach for "entity keys" are "nonsense numbers"; i.e. identities / generated id's. And they're central to Entity Framework's "tracking" ability. It's the "user" ids / keys that get transported between systems; so they better match (case-wise); unless it's "universal", like an email; in which "case", you can case it the way you want when comparing.

      "(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal

      L 1 Reply Last reply
      0
      • L Lost User

        Since you can do "like" and "sounds like" searches in SQL Server, you need to review your "requirements" more. For the record, the recommended approach for "entity keys" are "nonsense numbers"; i.e. identities / generated id's. And they're central to Entity Framework's "tracking" ability. It's the "user" ids / keys that get transported between systems; so they better match (case-wise); unless it's "universal", like an email; in which "case", you can case it the way you want when comparing.

        "(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Thank you, I need to think more about

        Quote:

        's the "user" ids / keys that get transported between systems; so they better match (case-wise); unless it's "universal", like an email.

        Thanks again Bruno

        L 1 Reply Last reply
        0
        • L Lost User

          Thank you, I need to think more about

          Quote:

          's the "user" ids / keys that get transported between systems; so they better match (case-wise); unless it's "universal", like an email.

          Thanks again Bruno

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          I find that the more systems I'm integrating with, the more I rely on creating "API's" where the object "getters" do some of the translating on the fly for a better or cleaner "view" within the context of the application. Molding reality.

          "(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal

          1 Reply Last reply
          0
          • L Lost User

            Hello experts I’m usually organizing the data internally using a “system” generated id (at the moment int generated by mssql sequences) to define primary keys and foreign key relations. That has sometimes advantages but on the other hand it is not really the clean way from the point of theory (and for data exchange it can be the real pain). Why? The user usually needs also to have his “user-id” which is the user’s primary… so with the way above I introduce an extra index. And basically the user primary should enough and should be used to define the db constraints. But programmers are lazy and like keys all of the same type…. Ok, long speech. What I’m really like asking for Best Praxis is: I’m at a point to migrate Interbase databases to MSSQL. Interbase has as default case sensitive indices while MSSQL has case insensitive as default. In case this “user-id” allows alphanumeric, what is better/best Praxis/usual: a.) Make Ids case sensitive ? b.) Make Ids case insensitive? Thank you in advance Bruno

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Store all in upper-case and go for insensitive. Wouldn't make much sense most of the time to have a record with and one without capitalization in the database, would it? For primary keys, I still recommend normalization. Your auto-generated identity is of little use to the user (and should not be visible).

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

            L 1 Reply Last reply
            0
            • L Lost User

              Store all in upper-case and go for insensitive. Wouldn't make much sense most of the time to have a record with and one without capitalization in the database, would it? For primary keys, I still recommend normalization. Your auto-generated identity is of little use to the user (and should not be visible).

              Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Quote:

              Wouldn't make much sense most of the time to have a record with and one without capitalization in the database, would it?

              That is exactly the Point for which I'm looking for. Completely agree with you. Thank you for confirming this.

              L 1 Reply Last reply
              0
              • L Lost User

                Quote:

                Wouldn't make much sense most of the time to have a record with and one without capitalization in the database, would it?

                That is exactly the Point for which I'm looking for. Completely agree with you. Thank you for confirming this.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                You're welcome :)

                Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

                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