We Can Do Better Than SQL
I wholeheartedly agree with the &quot;complaining&quot; part of the post, but then here comes the &quot;solution&quot; and I&#x27;m not quite sold.<p>I mean, I don&#x27;t necessarily claim that this is not a solution, it just isn&#x27;t obvious to me at all. Maybe a more extensive explanation with better examples would make it all clear to me and I&#x27;d be super-hyped about it already, but right now I&#x27;m more like confused.<p>First off, it would be helpful show the table structure in the examples, and then compare EdgeQL query to the easiest solution in the SQL. After all, the readers supposedly use SQL almost daily for many years (I know I do), but don&#x27;t know a thing about EdgeQL, so if it can do everything SQL can, but easier, such a comparison must make it pretty obvious.<p>TBH, my knowledge of the relational algebra is quite rusty by now, so maybe that&#x27;s the problem, but as I remember, many queries we commonly use with the SQL are not really &quot;relational&quot; queries. Relational algebra deals with the sets of tuples, so things like count(*) or ORDER BY, or GROUP BY are not really a part of relational model, they just exist because they are super-helpful in what we usually are trying to achieve with SQL.<p>The problems with NULL are of a similar nature. I don&#x27;t think we should pretend that NULL not being equal NULL is not useful (we don&#x27;t expect &quot;missing data&quot; to be exactly the same value as another &quot;missing data&quot;, do we?), and SELECT DISTINCT treating them as equals is not intuitive (for me it absolutely is: when I&#x27;m asking what values occur in a table, a missing entry is a missing entry to me, I don&#x27;t want to see NULL 10000 times).<p>So, the introduction kind of made me to expect the solution to be more in compliance with relational concepts, but it doesn&#x27;t seem to be, since all of the above are present in the EdgeQL in one form or another.<p>I&#x27;m not sure how {} is different from NULL in the EdgeQL, since {} seems to be kind of special thing here, the same as NULL is in the SQL. I mean, it doesn&#x27;t behave like a true empty set at all! Non-empty set {value} OR {} = {value}, not {} (OR ≡ ∪). &lt;bool&gt;{} being {} instead of a true boolean value looks even more confusing to me than NULL OR (NOT NULL) = NULL. Same ternary algebra here.<p>Then, I don&#x27;t really understand a concept of a flat set here. I do kind of understand what we are trying to achieve here: we want to solve the problem of SELECT x, (SELECT y) FROM z throwing an error in a runtime, if count(SELECT y) != 1. And it kind of would make sense in SQL, but it&#x27;s explicitly advertised as a feature of EdgeQL that it can return trees (json-like structures), and here it doesn&#x27;t seem to make sense that an output of a query (which is a &quot;flat set&quot;, I guess?) cannot have another set as an element. Moreover, it obviusly can be ordered, which also isn&#x27;t a property of how &quot;set&quot; is commonly defined in the set theory.<p>As a first impression, syntax and overall structure of the queries doesn&#x27;t strike me as obvious as well. In fact, since<p>&gt; SQL does not integrate well enough with application languages and protocols<p>I would ultimately hope for something that can be expressed as a number of function calls and commonly used data structures (a list, a dictionary&#x2F;record, etc.) in most&#x2F;any mainstream PLs, not a one more DSL as in &quot;free form text&quot;. (Maybe with a more succinct DSL for the use in a console. Maybe.)<p>And my ultimate source of confusion. SQL is more or less the same thing even in these DBMS where it isn&#x27;t exactly The SQL (like ClickHouse). And given I know the overall structure of the DBMS (like, is it, for instance, row-based or column-based?) I can make pretty good assumptions of performance of a given query, even though SQL is still declarative and I do not know what exactly the query-optimizer will do. Maybe it&#x27;s just that I&#x27;m not used to it, but I don&#x27;t have a feel about how performant would be the last EdgeQL example of the article, and if it would be better to separate it into several queries at some scale. In fact, I don&#x27;t even understand if it&#x27;s something that would be reasonable easy to implement in other major RDBMS&#x27;, or is it ultimately EdgeDB-only feature? If so, it can be only as good as EdgeDB — and is it as good as PosgreSQL, or MariaDB, or sqlite? Unfortunately, in the real world I have to worry more about how performant and robust a thing is under load, than I can worry about programming convenience.