A Better SQL in 11 Lines of Code

UCLA's RePL lab introduces Prela, a query language built on binary relations. This tutorial shows how to implement a toy version in Python, revealing that complex SQL joins can be expressed as simple relation compositions. By decomposing tables into two-column relations and using operators like `.select`, `&`, and `.where`, Prela composes queries that read like natural language. The result: a 20-line SQL query becomes an 11-line Prela expression, with the added benefit of composability and clarity.

The first special thing about Prela is that there are only binary relations, i.e., tables with two columns.
  1. petilon

    The example is not particularly impressive. The SQL equivalent is much easier to understand, which means it is easier to maintain. Number of lines is not an interesting metric; understandability and maintainability are more important.

  2. remywang

    Author here, I will be at VLDB in Boston this coming week and will be very happy to chat about Prela.

    Unrelated, we also have a tutorial on instance-optimal join algorithms: https://www.vldb.org/2026/program.html#tut-2

  3. grebc

    You’ve got do a better job selling the title sorry.

    I feel like the separation between a query & the query execution plan is one of the benefits of SQL. I trust the database system to do the right thing 99% of the time, and I don’t want to think about that either really.

  4. slowcache

    I think an important benefit of a good ORM is to reduce the translations that you have to do between your mental model of the data and what you are trying to do with the data.

    Before I started working a lot with SQL, ORMs fit my mental model better since I was more used to imperative programming languages and I thought they were easier to work with.

    Now that I am very comfortable with SQL, I have to translate an ORM into the SQL that it would produce. So now they just add another step in between me and the data

  5. Planktonne

    This seems harder to read than SQL, and only less verbose if you assume that an SQL database would be built with Prela's limitations in mind, which doesn't feel like a reasonable assumption.

More from this day

2026-08-29