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. Frustration

Frustration

Scheduled Pinned Locked Moved The Lounge
questiondatabaseregex
37 Posts 17 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.
  • M MadGerbil

    Why does the column name in my code have to match the column name in the database? It just feels so.... restrictive.

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

    string MyName => SomeOtherName;

    "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

    1 Reply Last reply
    0
    • M Mycroft Holmes

      Having worked on a system that used some of Jeremy's mapping alternatives I recommend that you NEVER do this, attempting to track through from a field name on a form/class that is different to the column name in the database is a nightmare. You would be just adding complexity for the sake of it, adding multiples to the support cost and the supporting dev will have a wax effigy of you and be sticking needles in it!

      Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

      J Offline
      J Offline
      Jeremy Falcon
      wrote on last edited by
      #9

      Mycroft Holmes wrote:

      Having worked on a system that used some of Jeremy's mapping alternatives I recommend that you NEVER do this

      I'm trying to collect $20 though...

      Jeremy Falcon

      1 Reply Last reply
      0
      • M Mycroft Holmes

        Having worked on a system that used some of Jeremy's mapping alternatives I recommend that you NEVER do this, attempting to track through from a field name on a form/class that is different to the column name in the database is a nightmare. You would be just adding complexity for the sake of it, adding multiples to the support cost and the supporting dev will have a wax effigy of you and be sticking needles in it!

        Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

        T Offline
        T Offline
        trønderen
        wrote on last edited by
        #10

        I have frequently seen that kind of arguments, and very similar ones, used to justify that end user with a vague idea about the meaning of English terms nevertheless have to accept them, because those are their real names, and using anything else would be confusing and misleading. It would be fascinating if Chinese hardware and software developer switched to a similar approach.

        P J 2 Replies Last reply
        0
        • T trønderen

          I have frequently seen that kind of arguments, and very similar ones, used to justify that end user with a vague idea about the meaning of English terms nevertheless have to accept them, because those are their real names, and using anything else would be confusing and misleading. It would be fascinating if Chinese hardware and software developer switched to a similar approach.

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #11

          More of a guideline really.

          1 Reply Last reply
          0
          • M MadGerbil

            Why does the column name in my code have to match the column name in the database? It just feels so.... restrictive.

            M Offline
            M Offline
            Mircea Neacsu
            wrote on last edited by
            #12

            Don't worry, it's just a temporary thing. Next migration will change the database column names and (dis)order will be restored in universe. ;P

            Mircea

            1 Reply Last reply
            0
            • T trønderen

              I have frequently seen that kind of arguments, and very similar ones, used to justify that end user with a vague idea about the meaning of English terms nevertheless have to accept them, because those are their real names, and using anything else would be confusing and misleading. It would be fascinating if Chinese hardware and software developer switched to a similar approach.

              J Offline
              J Offline
              jmaida
              wrote on last edited by
              #13

              LOL

              "A little time, a little trouble, your better day" Badfinger

              1 Reply Last reply
              0
              • M Mycroft Holmes

                Having worked on a system that used some of Jeremy's mapping alternatives I recommend that you NEVER do this, attempting to track through from a field name on a form/class that is different to the column name in the database is a nightmare. You would be just adding complexity for the sake of it, adding multiples to the support cost and the supporting dev will have a wax effigy of you and be sticking needles in it!

                Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

                D Offline
                D Offline
                David ONeil
                wrote on last edited by
                #14

                What's so hard about COL1, COL2, COL3? /s

                Our Forgotten Astronomy | Object Oriented Programming with C++ | Wordle solver

                M J 2 Replies Last reply
                0
                • S Slacker007

                  It sort of like calling people by another name, that is not theirs. "Hey Bob, how are you today?" "I'm not Bob, I'm Charlie!" "Who's Charlie? You must mean Debra. Wait right here, I'll get her/she/they/them." :laugh:

                  C Offline
                  C Offline
                  charlieg
                  wrote on last edited by
                  #15

                  Keep me out of this :)

                  Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                  1 Reply Last reply
                  0
                  • M MadGerbil

                    Why does the column name in my code have to match the column name in the database? It just feels so.... restrictive.

                    M Offline
                    M Offline
                    MikeCO10
                    wrote on last edited by
                    #16

                    So, I smiled when I read this, thinking of the because it's easy and makes sense answer. But really, this is a deeper question that depends on what language you are using and what the application interaction with the user is. I'm assuming you're comparing local variable names to the DB columns; and not accessing the actual DB object. There are cases where this may not be best practice and maybe a case could be made to argue it is not best practice at all.

                    1 Reply Last reply
                    0
                    • M MadGerbil

                      Why does the column name in my code have to match the column name in the database? It just feels so.... restrictive.

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

                      I assume you're not using an ORM? All the ORM's I've used (EF, Linq2SQL, Dapper, etc) have the ability to attribute the model with table and column aliases.

                      Latest Article:
                      Create a Digital Ocean Droplet for .NET Core Web API with a real SSL Certificate on a Domain

                      0 1 Reply Last reply
                      0
                      • M MadGerbil

                        Why does the column name in my code have to match the column name in the database? It just feels so.... restrictive.

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

                        Prefix tables with "tbl" and your code be happy.

                        Bastard Programmer from Hell :suss: "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

                        1 Reply Last reply
                        0
                        • M Marc Clifton

                          I assume you're not using an ORM? All the ORM's I've used (EF, Linq2SQL, Dapper, etc) have the ability to attribute the model with table and column aliases.

                          Latest Article:
                          Create a Digital Ocean Droplet for .NET Core Web API with a real SSL Certificate on a Domain

                          0 Offline
                          0 Offline
                          0x01AA
                          wrote on last edited by
                          #19

                          But why one should use different names? Is it not only make the things more confusing?

                          D Sander RosselS J 3 Replies Last reply
                          0
                          • D David ONeil

                            What's so hard about COL1, COL2, COL3? /s

                            Our Forgotten Astronomy | Object Oriented Programming with C++ | Wordle solver

                            M Offline
                            M Offline
                            Mycroft Holmes
                            wrote on last edited by
                            #20

                            As punishment for that you get sent to Q&A for a week!

                            Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

                            D 1 Reply Last reply
                            0
                            • M Mycroft Holmes

                              As punishment for that you get sent to Q&A for a week!

                              Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

                              D Offline
                              D Offline
                              David ONeil
                              wrote on last edited by
                              #21

                              If they ask for codez now I'll use those variable names! :laugh: :laugh: :laugh: I'm pretty certain I saw something like those in a BPCS system once... :sigh: I'm still trying to erase that memory.

                              Our Forgotten Astronomy | Object Oriented Programming with C++ | Wordle solver

                              1 Reply Last reply
                              0
                              • 0 0x01AA

                                But why one should use different names? Is it not only make the things more confusing?

                                D Offline
                                D Offline
                                David ONeil
                                wrote on last edited by
                                #22

                                Job insurance. ;P

                                Our Forgotten Astronomy | Object Oriented Programming with C++ | Wordle solver

                                1 Reply Last reply
                                0
                                • S Slacker007

                                  It sort of like calling people by another name, that is not theirs. "Hey Bob, how are you today?" "I'm not Bob, I'm Charlie!" "Who's Charlie? You must mean Debra. Wait right here, I'll get her/she/they/them." :laugh:

                                  Sander RosselS Offline
                                  Sander RosselS Offline
                                  Sander Rossel
                                  wrote on last edited by
                                  #23

                                  People do that all the time though :~ My grandma's are both named Elisabeth something something on their birth certificate/passport, but we call them Bep (quite a common name here for old people). I recently found out Dick is a nickname for Richard, Bill for William and Bob for Robert. A lot of people have birth names that are different from the names we actually call them (sometimes the names are at least related, but often they're not). And when a woman marries a man she suddenly gets a new last name (and is proud of it too). Luckily, all of these are getting more rare X| My complete name is simply Sander Rossel and that's what people call me too :D

                                  Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

                                  T 1 Reply Last reply
                                  0
                                  • 0 0x01AA

                                    But why one should use different names? Is it not only make the things more confusing?

                                    Sander RosselS Offline
                                    Sander RosselS Offline
                                    Sander Rossel
                                    wrote on last edited by
                                    #24

                                    Because the people that once designed the database gave their columns names like cicmpy (customer info company, or something like that, taken from a very popular financial system). Or because you're dealing with TextField1, TextField2,... TextField20, DateField1, DateField2,... DateField20, etc. "because the software should be flexible." (I have to admit, the software is flexible and works miraculously well, but their API is horrible).

                                    Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

                                    1 Reply Last reply
                                    0
                                    • Sander RosselS Sander Rossel

                                      People do that all the time though :~ My grandma's are both named Elisabeth something something on their birth certificate/passport, but we call them Bep (quite a common name here for old people). I recently found out Dick is a nickname for Richard, Bill for William and Bob for Robert. A lot of people have birth names that are different from the names we actually call them (sometimes the names are at least related, but often they're not). And when a woman marries a man she suddenly gets a new last name (and is proud of it too). Luckily, all of these are getting more rare X| My complete name is simply Sander Rossel and that's what people call me too :D

                                      Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

                                      T Offline
                                      T Offline
                                      trønderen
                                      wrote on last edited by
                                      #25

                                      Use of nicknames vary greatly from one culture / country to another. Here in Norway 99% of the population are called by their 'real' names - to the degree that Bill Bryson (yes, yet another Bryson quote!) tells in "Neither here nor there": "I had had huge difficulty persuading the staff at the Kredittkassen Bank on Karl Johans Gate to cash sufficient traveller's checques to pay the extortionate 1,200 kroner bus fare - they simply could not made to grasp that the William McGuire Bryson on my passport and the Bill Bryson on my traveller's cheques were both me" I've seen it from the other side as well: Don't expect every Norwegian to have a middle name. Today, it is seen more often, but in my generation, I hardly know of anyone with a middle name. I wanted some information from a USA web site that required me to create a user, asking for my real name, and they insisted on a "middle initial". American forms for specifying names almost invariably has a field for the middle initial, but you may leave it open. Not on this website, it insisted on an alphabetic character, A-Z. Space, hyphen or other punctuation marks were not accepted, you had to reveal your middle initial. Of course you have one - everybody have a middle initial! Sure, I don't think I've ever met anyone from the USA without a middle initial. We do use double first names: My best buddy in childhood was named Per Erik, one of my current friends is named Per-Kristian, my father was named Torleif (Tor Leif, but as one, unhyphenated word). The double name is always used in full: If you asked me when I was ten if I knew of any 'Per', Per Erik would never occur to me. Per-Kristian is not some 'Per' that I know today. If you suggest that my father was named Tor, I would protest; that is simply wrong. In my parents' generation, it was more common to have a double, unhyphenated first name, but use only one of them in everyday life. I knew my mother's other first name, but didn't know until several years after moving out from my parents' that my father had a another first name! They would never indicate the initial letter of the other first name as a "middle initial" - the other name is still a first name, not a middle name! The same goes for lots of other people of that generation that I know. I guess that one reason why we rarely use nicknames is that the major part of Norwegian first names are short, 1 or 2 syllables. All the 4-syllable names I can think of are really two concatenated names. Most, but not all, 3-syllable names are

                                      Sander RosselS 1 Reply Last reply
                                      0
                                      • 0 0x01AA

                                        But why one should use different names? Is it not only make the things more confusing?

                                        J Offline
                                        J Offline
                                        jschell
                                        wrote on last edited by
                                        #26

                                        0x01AA wrote:

                                        But why one should use different names?

                                        Certainly one reason is that databases have absolute length limits. So if you exceed that you are out of luck. As an example the Oracle column name length limit is 30. Additionally when database statements are constructed there are length limits on the total length of that. One of course should not normally run into that. Which is perhaps worse because what happens is that someone uses magical coding APIs without understanding what is actually happening and then when it fails for that one odd ball case then no one can figure out what is happening. Then there are things that happen over time. Such as a table that has a column named 'total' which even though the column is still named that, what is actually is now is the 'DailyTotal'. Column might be used in one place where in the code the attribute 'DailyTotal' is used in many places. So explaining what it actually is in every place becomes a problem.

                                        T 1 Reply Last reply
                                        0
                                        • T trønderen

                                          Use of nicknames vary greatly from one culture / country to another. Here in Norway 99% of the population are called by their 'real' names - to the degree that Bill Bryson (yes, yet another Bryson quote!) tells in "Neither here nor there": "I had had huge difficulty persuading the staff at the Kredittkassen Bank on Karl Johans Gate to cash sufficient traveller's checques to pay the extortionate 1,200 kroner bus fare - they simply could not made to grasp that the William McGuire Bryson on my passport and the Bill Bryson on my traveller's cheques were both me" I've seen it from the other side as well: Don't expect every Norwegian to have a middle name. Today, it is seen more often, but in my generation, I hardly know of anyone with a middle name. I wanted some information from a USA web site that required me to create a user, asking for my real name, and they insisted on a "middle initial". American forms for specifying names almost invariably has a field for the middle initial, but you may leave it open. Not on this website, it insisted on an alphabetic character, A-Z. Space, hyphen or other punctuation marks were not accepted, you had to reveal your middle initial. Of course you have one - everybody have a middle initial! Sure, I don't think I've ever met anyone from the USA without a middle initial. We do use double first names: My best buddy in childhood was named Per Erik, one of my current friends is named Per-Kristian, my father was named Torleif (Tor Leif, but as one, unhyphenated word). The double name is always used in full: If you asked me when I was ten if I knew of any 'Per', Per Erik would never occur to me. Per-Kristian is not some 'Per' that I know today. If you suggest that my father was named Tor, I would protest; that is simply wrong. In my parents' generation, it was more common to have a double, unhyphenated first name, but use only one of them in everyday life. I knew my mother's other first name, but didn't know until several years after moving out from my parents' that my father had a another first name! They would never indicate the initial letter of the other first name as a "middle initial" - the other name is still a first name, not a middle name! The same goes for lots of other people of that generation that I know. I guess that one reason why we rarely use nicknames is that the major part of Norwegian first names are short, 1 or 2 syllables. All the 4-syllable names I can think of are really two concatenated names. Most, but not all, 3-syllable names are

                                          Sander RosselS Offline
                                          Sander RosselS Offline
                                          Sander Rossel
                                          wrote on last edited by
                                          #27

                                          Mandatory middle name? :~ An ex-coworker had a girlfriend from Indonesia, and where she's from they simply don't have a last name... Apparently, it's legal in the Netherlands to not have a last name as long as you don't have the Dutch nationality. As soon as you get Dutch nationality you need to pick a last name. Anyway, she didn't have a last name officially, but for most forms she had to use her made up last name (which was official-ish, I guess). What's more, they got a child, and a first child can have the last name of the mother or the father. Most pick father, but they picked mother, so the child doesn't have a last name either. I believe (s)he(?) gets to pick both his nationality and last name when (s)he turns 18.

                                          Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

                                          T 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