If you’re modeling relational data, it doesn’t seem like you can get around using a DB that uses SQL, which to me is the worst: most programmers aren’t DB experts and the SQL they output is quite often terrible.

Not to dunk on the lemmy devs, they do a good job, but they themselves know that their SQL is bad. Luckily there are community members who stepped up and are doing a great job at fixing the numerous performance issues and tuning the DB settings, but not everybody has that kind of support, nor time.

Also, the translation step from binary (program) -> text (SQL) -> binary (server), just feels quite wrong. For HTML and CSS, it’s fine, but for SQL, where injection is still in the top 10 security risks, is there something better?

Yes, there are ORMs, but some languages don’t have them (rust has diesel for example, which still requires you to write SQL) and it would be great to “just” have a DB with a binary protocol that makes it unnecessary to write an ORM.

Does such a thing exist? Is there something better than SQL out there?

  • r1veRRR@feddit.de
    cake
    link
    fedilink
    arrow-up
    11
    arrow-down
    4
    ·
    9 months ago

    I’d recommend everyone check out https://prql-lang.org/. It’s SQL, but readable and writable in a sane way.

    And no, SQL is NOT readable or writable for anything involving more than a single join.

    • BitSound@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      9 months ago

      I’m pretty excited about PRQL. If anything has a shot at replacing SQL, it’s something like this (taken from their FAQ):

      PRQL is open. It’s not designed for a specific database. PRQL will always be fully open-source. There will never be a commercial product.

      There’s a long road ahead of it to get serious about replacing SQL. Many places won’t touch it until there’s an ANSI standard and all that. But something built with those goals in mind actually might just do it.

    • BehindTheBarrier@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      9 months ago

      I’m not too much of a fan of the SQL equivalent of SELECT not being at the top. Granted I’m fairly sure there are some arguments for it. Since select is optional there’s a higher mental load trying to figure out where and what is actually being returned imo. At least from looking at this for the first time.

      On the other hand, i’d kill for f-strings, the top N in group (which is nigh unreadable in SQL), and null handling that doesn’t require me to write either COALSECE or NVL too often. The joins were a little less pretty though, I’m quite fond of normal SQL joins since they are very reasonable unless chained beyond the line count your screen can show.

    • luckystarr@feddit.de
      link
      fedilink
      arrow-up
      1
      arrow-down
      1
      ·
      9 months ago

      You can write selects with many joins, as long they are regular and either add a column or reduce the result set. You have to write the joins explicitly though. Just shoving all of the restrictions into the where clause will definitely confuse everybody.