• xmunk@sh.itjust.works
    link
    fedilink
    arrow-up
    123
    arrow-down
    2
    ·
    11 months ago

    Speaking as a Senior Dev specialized in database access and design… you don’t have to use all caps - SQL is actually case agnostic.

    But… but my fucking eyes man. I’m old, if your branch doesn’t have control keywords in all caps I’m going to take it out back and ol’ yeller it.

    There are few hills I’ll die on but all caps SQL and singular table names are two of them.

    • erogenouswarzone@lemmy.ml
      link
      fedilink
      English
      arrow-up
      19
      arrow-down
      1
      ·
      11 months ago

      The place I work decided to name all tables in all caps. So now every day I have to decide if I want to be consistent or I want to have an easy life.

      • xmunk@sh.itjust.works
        link
        fedilink
        arrow-up
        9
        ·
        11 months ago

        Fuuuuck. That’s why I love postgres… and fuck anyone that requires double quoted identifiers for special casing.

        • icydefiance@lemm.ee
          link
          fedilink
          arrow-up
          6
          ·
          edit-2
          11 months ago

          Postgres normalizes table and field names to lowercase, unless you put them in quotes. It’s also case sensitive.

          That means if you use quotes and capital letters when creating the table, then it’s impossible to refer to that table without using quotes.

          It also means if you rename the table later to be all lowercase, then all your existing code will break.

          Still a much better database than MySQL though.

          • xmunk@sh.itjust.works
            link
            fedilink
            arrow-up
            2
            ·
            11 months ago

            I’m quite aware… basically it means that novice devs can create a table in camelCase and query in camelCase… but you can clean it all up as long as they didn’t realize you needed double quotes.

            • icydefiance@lemm.ee
              link
              fedilink
              arrow-up
              2
              ·
              edit-2
              11 months ago

              Fair point. I always disliked the design because ORMs pretty much always use quotes, so an entity-first approach can create a lot of tables with capital letters if you’re not careful, which is then really annoying if you need to use raw SQL for anything.

      • xmunk@sh.itjust.works
        link
        fedilink
        arrow-up
        15
        ·
        11 months ago

        It’s an English literacy thing - we have several non-native English speakers and using only singular avoids making those folks’ lives harder. Besides it’s really nice to autopilot that categoryid is a foreign key to the category table. It also simplifies always plural words… I haven’t yet written CREATE TABLE pants but if I ever do there’s zero chance of me creating a pantid.

          • xmunk@sh.itjust.works
            link
            fedilink
            arrow-up
            4
            ·
            11 months ago

            I tend to use underscores on join tables so table foo_bar would have a fooid and a barid. I have somewhat soured on this approach though since there are a lot of situations where you’ll have two m-m relationships between the same two tables with a different meaning… and having a fixed formula for m-m tables can make things ugly.

            If I get to design another greenfield database I’ll probably prefer using underscores for word boundaries in long table names.

        • Faresh@lemmy.ml
          link
          fedilink
          English
          arrow-up
          4
          ·
          11 months ago

          I always thought they should be singular to be closer to the names we give entities and relations in a entity-relation diagram.

      • Skyrmir@lemmy.world
        link
        fedilink
        arrow-up
        8
        ·
        11 months ago

        Look at you with your color vision being all elitist. Some of us old bastards don’t see them pretty rainbows so much any more.

    • Nolegjoe@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      11 months ago

      I’m a sql developer, and I am completely the opposite to you. I will find it incredibly difficult to read when everything is in caps