TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A Short Story About SQL’s Biggest Rival

256 pointsby huyover 4 years ago

26 comments

alquemistover 4 years ago
&gt; … The language (SQL) is not very composable. This is a fact that most SQL users are not aware of. The relational algebra that SQL is based on is absolutely composable but SQL is not due to the inherent limitation of the language (as it was designed to be natural language-like). When you write &quot;select x from a where z&quot;, you are actually building something along the lines of &quot;from a&quot; =&gt; &quot;where z&quot; =&gt; &quot;select x&quot; in the algebra and you can actually compose each portion separately. If you are familiar with dplyr, Spark or pandas you would get this instantly.<p>Hmmm. Not a big lover of SQL, but this is a bit imprecise. While the unit of composability is slightly smaller for from=&gt;where=&gt;select (expression) vs select+from+where (subquery), in practice they both encode the same fundamental compositional principles, based on relational algebra. Any from=&gt;where=&gt;select query can be translated into a select+where+from query almost 1:1, if only via:<p><pre><code> from t ::= select * from t q =&gt; where p ::= select * from q where p q =&gt; select xs ::= select xs from q </code></pre> Sometimes the select+where+from ends up more verbose, sometimes there is more brain twisting to grok a given select+where+from query, but that&#x27;s not a composition limiting factor. Granted, the readability of SQL is sometimes lacking, but it is fully capable to compose recursive relational algebra queries.
评论 #24733494 未加载
评论 #24733922 未加载
评论 #24733640 未加载
jhallenworldover 4 years ago
I don&#x27;t like either syntax. Wikipedia has this example:<p>QUEL:<p><pre><code> range of E is EMPLOYEE retrieve into W (COMP = E.Salary &#x2F; (E.Age - 18)) where E.Name = &quot;Jones&quot; </code></pre> SQL:<p><pre><code> select (e.salary &#x2F; (e.age - 18)) as comp from employee as e where e.name = &quot;Jones&quot; </code></pre> I would prefer an operator syntax that directly mimics relational algebra. Something like:<p><pre><code> w = employee(name == &quot;Jones&quot;)[comp = salary &#x2F; (age - 18)] </code></pre> So () is &quot;where&quot;, [] is &quot;project&quot; (choose or create columns) and you can use * for join and + for union. The result is a table with a column named comp.
评论 #24735278 未加载
评论 #24737600 未加载
评论 #24736550 未加载
评论 #24735454 未加载
评论 #24737942 未加载
评论 #24734956 未加载
评论 #24734498 未加载
me2i81over 4 years ago
In my first job I used Ingres&#x2F;Quel. Probably because of that, I still find SQL hideous. Quel was a lot more orthogonal and clean, but by now SQL has so many more features that they&#x27;re not really comparable. The first version of Ingres ran on a PDP-11&#x2F;70, and the different components (parser, query optimizer, query executor, etc.) ran in separate processes connected via pipes (this was pre-socket Berkeley Unix) because each process could only be 64K 16-bit words. It was hideously slow--ran a lot faster once it was ported to the VAX and everything could run in one process. INGRES originally stood for something like Interactive Graphics Retrieval System, IIRC because the original funding agency wanted a graphics database. Stonebraker wanted to build a relational DBMS so he just went ahead and did it, but gave it a grant-compliant name and wrote some bullshit about graphics to make the funding agency happy.
jp0dover 4 years ago
I agree with some of the comments about composabilty of SQL. I&#x27;ve been doing SQL since more than 14 years. Most of it was spent working on ETL projects for Finance and Utilities industries. Even today 80% of the code I write in pySpark is just plain SQL. It&#x27;s been my bread and butter. However, I spend a lot of time trying to think about a solution in SQL. It&#x27;s not an easy language to use when it comes to implementing complex transformations. I could write the same logic in Python in a lot less time. I use SQL mostly because it&#x27;s easily portable across systems and most analysts and to some extent tech managers understand it. I work primarily on proof of concept data products and it does the job for that. Then a real developer takes over and implements it in .Net.
hn_throwaway_99over 4 years ago
Minor point, and others have brought up more details around composability, but I think it&#x27;s an absolute mistake to reference properties on an object before that object is declared. I.e. if SQL had the FROM clause before the SELECT clause autocomplete support could be much more intelligent about helping with SELECT columns.<p>Same problem with declaring imports in javascript. Python got it correct, where I write e.g. &#x27;from somemodule import ...&#x27;, so by the time I get to the import the parser has enough info to help with autocomplete. Javascript&#x27;s &#x27;import { Something } from &quot;foo&quot;&#x27; means the parser can&#x27;t help me autocomplete Something.
评论 #24736418 未加载
Ericson2314over 4 years ago
Good history.<p>But, thanks to <a href="https:&#x2F;&#x2F;github.com&#x2F;haskell-beam&#x2F;beam" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;haskell-beam&#x2F;beam</a> I no longer need to worry about the COBOL-ness of SQL without giving up the semantics. Finally!
TehShrikeover 4 years ago
I&#x27;d been aware of Codd&#x27;s relational theory, but never heard of QUEL – now I want to find a database engine that implements QUEL!
评论 #24731969 未加载
评论 #24731750 未加载
评论 #24736383 未加载
samatmanover 4 years ago
&gt; <i>In a real coup we hired a superb team from Xerox PARC.</i><p>Once again, California&#x27;s absence of noncompetes plays a critical role in the success of a business.
timparkover 4 years ago
Long ago, I worked for a company that had to convert its entire accounting system from QUEL to SQL. Fortunately, I was able to write a parser to find the queries and rewrite them, at least for whatever subset of the language they used. It&#x27;s been a while, but I think there was an issue with multi-query transactions, so the program warned that you&#x27;d have to convert and&#x2F;or verify some parts yourself, but fortunately there weren&#x27;t too many of those.
geophileover 4 years ago
Dupe: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24709031" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24709031</a><p>As I said the last time this came around: The end of this isn&#x27;t quite right. The Postgres project started in 1986. I don&#x27;t recall what language it used, QUEL perhaps, but it wasn&#x27;t SQL. SQL support was added between 1994 and 1996, and that&#x27;s when PostgreSQL was born.
评论 #24733207 未加载
评论 #24732142 未加载
评论 #24731605 未加载
cafardover 4 years ago
&quot;Mike Stonebraker of Ingres didn’t even bother to show up at the committee meeting to make the (quite strong) case for adopting QUEL because he was ideologically opposed to setting technology standards. It was the behavior of an intellectually arrogant academic rather than a prudent businessman protecting the interests of his company.&quot;<p>Some might call the behavior principled, rather than arrogant.
评论 #24733616 未加载
评论 #24734371 未加载
tannhaeuserover 4 years ago
Had expected to read sth about Datalog, rivaling SQL at least in academic DB literature.
评论 #24739106 未加载
评论 #24736131 未加载
ilakshover 4 years ago
This is a fundamental difference that I have with almost all of humanity.<p>People do not know the difference between popularity and merit. They don&#x27;t realize that the reason we do things is because that is how we do things. And they put a lot of effort into rationalizing the way we do things, without realizing the subconscious psychological (rather than rational) basis for that.<p>Most people fundamentally are generally unable to question assumptions about technology or how the world works.<p>This is one reason why, even though I am rooting for the human species, I am doubtful we will be able to stay relevant for long as autonomous general machine intelligence is built and deployed.<p>Even with extensive augmentation, it&#x27;s obvious that there are just severe limitations to the human mind.<p>The nice thing is that we have the opportunity to design successors that will not be limited in so many ways.
mamcxover 4 years ago
I&#x27;m working in a relational language that if it work as I wish, could eventually be put on top of a RDBM like sqlite or layer for other DBs:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;Tablam&#x2F;TablaM" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Tablam&#x2F;TablaM</a><p>It have ideas similar to QUEL...
评论 #24733557 未加载
nlover 4 years ago
Composition might be desirable but in the 1980s and early 90s it didn&#x27;t really matter because the databases of the day weren&#x27;t powerful enough to do the multiple table joins where composition is useful with enough speed to be usable.<p>DBAs of the day would spend a long time optimising physical storage of tables and building aggregation tables to make up for this performance deficit.
exabrialover 4 years ago
Really the the only issue I have with SQL is NULL != NULL. This creates an impedance mismatch with most languages...<p>MySQL sort of solves this problem with a &lt;=&gt; operator, which I wish was the default for ORMs to use.<p>There are a lot of other minor nitpicks but a lot of criticisms come down to the actual RDMS not SQL itself.
评论 #24734114 未加载
评论 #24734669 未加载
评论 #24733694 未加载
评论 #24733303 未加载
评论 #24737206 未加载
评论 #24733451 未加载
评论 #24734776 未加载
评论 #24732965 未加载
jrochkind1over 4 years ago
can anyone find examples of what QUEL looked like?<p>If we had a more composable query language being used instead of SQL, I wonder if that would have effected the course of ORMs, which arguably end up being as much about composable models of queries as they do about actual object mapping.
评论 #24733562 未加载
评论 #24740328 未加载
hackerfromthefuover 4 years ago
Would anyone familiar with both LINQ and QUEL be able to comment on similarities and differences?
mitchtbaumover 4 years ago
The path forward <a href="https:&#x2F;&#x2F;github.com&#x2F;speakeasy-engine&#x2F;speakeasy&#x2F;issues&#x2F;26" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;speakeasy-engine&#x2F;speakeasy&#x2F;issues&#x2F;26</a>
somurzakovover 4 years ago
SQL is perfect. if you want composability of SQL, just do SQL code-generation with your bare hands and compose whatever and however you want
brian_hermanover 4 years ago
I want him to continue telling the Postgres Story.
unnouinceputover 4 years ago
Quote: &quot;Of course, there was a silver lining to the whole saga. Stonebraker had forked the Ingres codebase in 1982 to create his company. Defeated by the bruising database wars of the 80s, he returned to Berkeley in 1985, and started a post-Ingres database project. Naturally, he named that database post-gres — as in, after Ingres.<p>And thus PostgreSQL was born.&quot;<p>And 35 years later PostgreSQL is kicking Oracle&#x27;s butt at every corner.
jgalt212over 4 years ago
&gt; technically superior alternatives like Dvorak and Esperanto would have taken over.<p>The best thing about English is the lack of accent marks. Makes each glyph unique (other than casing). Sorts are faster and not ambiguous.
评论 #24734789 未加载
eeccover 4 years ago
are there any usable implementations of QUEL in the wild?
kmeisthaxover 4 years ago
&gt;If the world worked differently, we wouldn’t still be writing on QWERTY keyboards, or speaking English; technically superior alternatives like Dvorak and Esperanto would have taken over.<p>Bad metaphor: There is no evidence for Dvorak&#x27;s technical superiority to QWERTY, neither is there for Esperanto over other languages.
评论 #24732725 未加载
评论 #24732648 未加载
评论 #24733076 未加载
评论 #24733265 未加载
nendroidover 4 years ago
The article talks about how SQL lacks composability. I would like to know everyones thoughts about this.<p>This is a huge issue with programming in general not exclusive to SQL. Everyone would like to build programs that are modular and reusable but programming paradigms have been traveling in directions that prevent this from happening. Many people turn to design patterns or microservices to try to deal with this organizational issue but they fail to see that the lower level programming paradigm itself is the precursor to the problem.<p>In SQL the problem occurs in the statement itself. The WHERE clause or the SELECT clause cannot be reused anywhere else. I can&#x27;t modularize a where clause and put it in another SQL statement. I have to rewrite the entire clause to reuse it.<p>In OOP the same issue occurs. In OOP your class tends to contain methods that are not combinators, or in other words methods that modify a free variable. Due to this like the SQL expression, Objects cannot be decomposed either. I cannot reuse a setter in another class or anywhere else outside of the context of the free variable it modifies.<p>In both cases there comes a time in the future of an application where programmers realize that similar logic could be reused but structural problems are preventing the reuse from happening so they have to implement a hack to get around it.<p>The issue is that everyone is unaware of this trend at a low level. They are unaware that SQL lacks composability just like how they are unaware that OOP lacks composability as well. But they are aware of this issue at a higher level and they tend to call it &quot;technical debt&quot; or some high level design problem.<p>Case in point: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24732789" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24732789</a><p>Most commenters above talk about minor syntactical issues and fail to address what is not only IMO the main issue, but the main issue that the article itself is addressing. Likely because they&#x27;re all unaware of the true nature of the composability issue and just didn&#x27;t completely understand what the article was saying.<p>Also note that when I talk about composition in OOP I am not talking about &quot;object composition.&quot; These are completely different usages of the word.
评论 #24734377 未加载
评论 #24734030 未加载
评论 #24733705 未加载
评论 #24736270 未加载