1. 20
  1. 7

    How does this new relational query language compare to the family of relational query languages specified by TTM / The Third Manifesto / Tutorial D, based on the relational algebra? The sales pitch for PRQL (a small number of powerful, orthogonal primitives that can be freely composed together, more expressive than SQL) sounds like the sales pitch for TTM and the relational algebra, so is there a connection?

    1. 5

      Very good question! It’s unfortunate that virtually all “SQL but better” initiatives don’t bother to look at the solid foundations of relational algebra and relational calculus, and more specifically the third manifesto manifestations. I’m not saying there are no further improvements to be made, but that should be the starting point.

      1. 2

        I’m surprised that you thought about D. To me D is “Relations are everything. You’re going to think and write in terms of types and relations. So much relations that we won’t even list ordering in examples.”

        On the other hand PRQL is “Lines are pretty much joined by and-then. You write imperative-ish code and we’ll do relations in the background.” I see them almost like opposite ideas that compile to the same lower language.

        1. 1

          Love to see Tutorial D mentioned. My favorite implementation is Alf in Ruby since it taught me the most.

        2. 2

          This looks very promising. Whenever I introduce someone to SQL, one of the first things I say is “yes, the order of these clauses makes no sense, but it’s too late now!”.

          1. 2

            Reminds me a lot of fluxql for time series https://docs.influxdata.com/influxdb/v2.4/query-data/get-started/query-influxdb/

            I love the progress in this area and the fact that there are so many projects trying something to improve the situation. It feels like it’s only a matter of time until one of the big databases picks up some other syntax.

            The day I can use this natively:

            from employees
            group role (
              sort join_date
              take 1

            I’m going to celebrate, because it’s one of those really common things that has 10 different non standard solutions depending on the specific database you’re using.

            1. 6

              What I would love to see is databases exposing a virtual machine with relational operations. Then you could plug a syntax into the DB and have almost native support. I know that some databases like SQLite already use a virtual machine. I just don’t know how accessible it is.

              1. 3

                This is called “execution engine” and yes we are moving to that direction. See Introducing Velox: An open source unified execution engine.

                1. 3

                  The SQLite virtual machine is pretty low-level and describes the exact query plan — that is, it’s the output of the optimizer. You could write another language that compiled to it, but you’d have to implement your own optimizer, which is most of the work.