96 points · by fny · 4y ago · 210 comments
Fundamentally, SQL lacks meaningful abstraction, and there's no sane way to package very common operations.
Say you want to find elements in a row that correspond to some maximum value when grouped by date. Today, you'd need to write something like this EVERY SINGLE TIME:
``` SELECT sd1.sale_person_id, sd1.sale_person_name, sd1.no_products_sold, sd1.commission_percentage, sd1.sales_department FROM sales_department_details sd1 INNER JOIN (SELECT sale_person_id, MAX(no_products_sold) AS no_products_sold FROM sales_department_details GROUP BY sale_person_id) sd2 ON sd1.sale_person_id = sd2.sale_person_id AND sd1.no_products_sold = sd2.no_products_sold; ```
Wouldn't something like this be nicer?
``` SELECT sale_person_id, max(no_products_sold) as max_sold, link(sale_person_name, max_sold), FROM sales_department_details ```
Frankly, it seems like some sort of macro system is needed. Perhaps the SQL compiles into the above?
For me the value of being able to walk up to an unfamiliar database of widely varying tech and start getting value out of it immediately is the killer app. Macros or other DB-specific extensions would be useful at times, but I’m not sure how much they would enable solving the messiness problem in a generic way that reshapes the paradigm more broadly. My instinct is the messiness is a consequence of the direct utility and trying to make it nicer from a programmerly aesthetics point of view might be hard to sell. It’s not like SQL doesn’t have affordances for aesthetics already (eg. WITH clauses).
- Queries that are difficult to interpret/verify.
- Non trivial amount of effort to go from question to query: I often feel like I have to jump through hoops to obtain something trivial. I have to think, and I don't want to think.
> Fundamentally, SQL lacks meaningful abstraction
My RDBMS course at college was really hardcore and SQL code answers for exam questions were enormous.
One neat trick they didn't teach us, but still perfectly legal SQL:1999, is to use WITH recursive constructs.
This way you can decompose very complex queries into simple ones, that can tested independently.
Also, integrating aggregate functions along with row_number() and similar functions to perform more complex work with less code.
IMHO declarative and relational algebra are orthogonal concepts. And why do you say SQL is relational algebra in disguise (paraphrased) ? Most introductions to SQL I've read, but certainly the SQL page on Wikipedia [1], starts with a remark about Codd's relational model. Granted SQL does not implement it perfectly, and it is not perfectly declarative, although that is a matter of taste.
> Non trivial amount of effort to go from question to query: I often feel like I have to jump through hoops to obtain something trivial.
I've had colleagues which expressed similar sentiments, but I have the opposite impression. I think I can express many queries on a much higher abstraction level than with most other languages.
> I have to think, and I don't want to think.
Not wanting to think while writing code is an understandable wish, but also a big red flag about developers for me. Even the best AI with perfect mind reading capabilities will not be able to execute the query you want, if you don't know what you want yourself. Even the AI would guess sometimes right, you would have no way of knowing whether it was right or wrong.
Dude... these are simple queries. I have *far* more important things to ponder than the specific incantations needed to get one of the values that correspond to a maximum.
At least SQL is old enough to get plenty of relevant search results. You can be a copy-paste DJ if you really can't figure it out.
I find 80% of queries that people want across a company are trivial.
I’d have saved myself many many hours over the years if people could just ask a question in natural language rather than asking me to write a query.
Hell they even have a name for databases specialized for this usecase — OLAP
The problem is that databases, and SQL, are such a pain to extend and define sufficiently general operations that you don’t just have scipy in the database, and thus your complicated analytics have to be fully specified with the few rudimentary analytic functions that are actually provided to you.
https://docs.timescale.com/timescaledb/latest/how-to-guides/...
https://duckdb.org/2022/05/04/friendlier-sql.html
It's a shame that so many people regard SQL using the reference SQL92 spec when in fact that it is continually evolving and improving like any other language still in use.
Still, views are free aren't they? Might as well create a view even if it is just for one query.
That said, it almost certainly is a better idea to write a connector to something like Trino and just build on its capabilities rather than write your own SQL interface.
I did appreciate the SQL interface, but as poster said, thinks could be a lot better, especially for exploratory analysis.
smh...
I’ve generally used it as a step in a data pipeline, where some intermittent state or aggregation where being stale/stable for a period of time is ok. Did this recently for a daily trends report on some news data - live querying the data is slow, but baking it off into a MV makes it much faster and keeps the query result from changing too rapidly to new data.
This is outdated; most modern DBs treat views as they would CTEs. If you don’t reference a defined field downstream, it doesn’t need to get calculated.
(Or maybe my knowledge is outdated and the optimizers have gotten way better than they were 3-4 years ago.)
Imagine wanting something as simple as "find_percentile_value(table, column, percentile)". There is no portable and standard way to write this parametric abstraction and then reuse it on any column source you need to interrogate later.
It's _every single time_ you need to do this kind of trivial querying you have to write this convoluted mess of SQL.
It's been an ANSI standard for 36 years.
They used to say the problem with C (especially with respect to memory issues) was that people didn't know it well, which was also true to some extent, but then we realized that we could improve language design to not leave people in that situation in the first place. Something like Rust would have never materialized if people simply took the attitude that you just need to hunker down and know C harder.
SQL is ripe for a similar evolution, but such evolution is difficult when the only reason we settled on SQL in the first place was to be compatible with Oracle and Oracle has no reason to change as long as the money keeps flowing in. The competition was going down some other interesting paths for a while. Even Postgres originally used QUEL, which is much closer to Codd's original vision, instead of SQL but eventually had to accept that Oracle won. But does Oracle need to win forever?
Agreed with "one of", but the most common programming language is definitely Excel.
https://www.sql-workbench.eu/dbms_comparison.html
One day I just sat down and learned about every item on that table. Not memorizing, just learning what it was for. Not only did my concept of what you can do with a database expand dramatically but also the limitations of insisting on hacking up equivalents in your own application code.
It's amazing how many steps can be skipped and race conditions can be avoided by leaning into the SQL.
The right views, applied in the right places are like a super power compared to trying to do the same thing in application code.
Soon I discovered window functions so that I could, for instance, get my data back with an extra column with the total number of rows, or the data in the first and last rows, and so on.
These little things had a large impact on the number of lines of Java that I had to write.
SQL views are useful for that kind of thing too.
This can definitely cause issues. I’ve seen queries with CTEs that basically process unindexed 100 MB data due to querying the materialized rows.
It would be cool to be able generate indexes with the CTEs though
Not sure which engine you're using, but for MSSQL at least, the engine writes stuff to disk where it can index it so that it can avoid table scans on retrieval. That is ideal where you have big joins or large tables. And is generally good for most use cases.
When you use CTE's you're telling the engine, "I want this in memory, don't do any indexing." That's awesome for write heavy workloads. But if you plan on joining the results of the CTE later, you will find that you can't read from it very quickly because for every row joined you must scan the entire table.
Now you'd think that since it's also forcing the data to stay in memory (if there's enough) that this would be faster. But that's not true. There's compute power at work to make comparisons on each row. The point of indexing is to reduce the required compute power by reducing the number of rows that you need to compare.
With that in mind, it's obvious that it kills performance if you just told your engine to not use indexes but do a big join on a large set of data.
Temporary tables are a better choice for read heavy workload compared with CTEs. MSSQL will index temp tables automatically. And in very rare cases where the automatic indexes aren't performant, then you can index them manually with a few extra keywords.
Happy querying.
I'm a principal engineer who is relatively new with SQL (just learned it 5 years ago, using it for a side project, not my daily work) and almost completely self-taught; and the biggest problem I have with SQL is that I find it nearly impossible to do even basic levels of DRY in a way that's not ugly.
Another issue is that the “SELECT” is also part of the function, which makes it even worse - so you can’t create just one function and reuse it all over the place. If only you could tell SQL that a certain JOIN always contains one row, or zero or one row (for a LEFT JOIN), then there would be more room for optimization.
I don't see any reason that the "select" limits reusability. If you define your function with relevant parameters you can create theoretically infinite reusability.
WITH cte1 AS ( /* whatever / ), cte2 AS ( / you can refer to cte1 here / ), cte3 AS ( / you can refer to cte1 and cte2 here */ ), ...
If I need access into multiple statements that I can't refactor into a single one, explicitly using temporary tables is a viable option (some engines implement CTEs and other operations using implicit temporary tables anyway). Otherwise, yes, views.
SELECT * FROM
(SELECT DENSE_RANK() OVER ( PARTITION BY sd1.sale_person_id ORDER BY sd1.no_products_sold DESC) r ,sd1.sale_person_id ,sd1.sale_person_name ,sd1.no_products_sold ,sd1.commission_percentage ,sd1.sales_department
FROM sales_department_details sd1) sd
Where sd.r = 1
do the same without the inner join?
[0] https://www.edgedb.com/ [1] https://www.edgedb.com/showcase/edgeql
Views, materialized views, CTEs.
Say I have a table with the following properties:
- It has a column that corresponds to an id
- It has a column that corresponds to a category
- It has a column that corresponds to a value
- It has a column that corresponds to a timestamp
- It has a bunch of other columns
I want to have a general transformation that allows me to:
Select an aggregate min, max over a period of time for a given category along with the other columns linked to min/max.
The stored procedure ends up being a mashup of string concatenation. Meanwhile, it just feels something is missing to make the language expressive enough.
The min/max aggregations over a period of time per category is pretty straight forward (aggregating rows), but what do you mean by "along with the other columns linked to min/max"? How would other columns come into play after aggregating rows?
Like say you have a query that applies to one table and potentially others where the column names are slightly different. Why cant you just port that query?
Difficult to be sure what you mean, but I think you're wrong. You can select from any table source (edit: result set, if you prefer that term).
> Select an aggregate min, max over a period of time for a given category along with the other columns linked to min/max.
select min(category) as mincat, max(category) as maxcat,
min(value) as minval, -- etc
where ts between <start> and <end>
I am not sure what you're asking for if the above is not it. Can you give an example please?You can copy, paste and edit 100 times and create 100 view objects
Or in eg numpy-python, you’d write a single function taking the table/columns as arguments, and reuse it.
I think the usual SQL solution would be to implement a stored function and start smashing strings together
[1]: https://carlineng.com/?postid=sql-critique#blog [2]: https://carlineng.com/?postid=malloy-intro#blog
I don’t see Malloy fixing it as it’s still using many English words and trying to be too much “sentence like”, but maybe I read it wrong
Agree, SQL can already do what the OP proposes in almost the exact same syntax.
and together with CTEs, intermediate temp tables or views, you can totally avoid the spaghetti and break down the queries in manageable chunks.
https://www.postgresql.org/docs/14/ddl-generated-columns.htm...
> A generated column is a special column that is always computed from other columns. Thus, it is for columns what a view is for tables.
eg.
SELECT col1, col2, col3(t) FROM table_name t;
This is how Postgraphile solved the problem to great effect. https://www.graphile.org/postgraphile/computed-columns/
you can simply assign a subquery to a variable and reuse it.
PS: a lot of you are saying use views. thats dangerous. In most cases, thats a nice way to end up with ballooning autovacume processes as your databasse gets bigger. Materialized views are fine as long as your use case doesn't need realtime accuracy.
select sale_person_id, sale_person_name, no_products_sold, commission_percentage, sales_department from sales_department_details natural join max_products_sold;
Just asking for mooar build in stuff just leads to bloated software.
https://www.scattered-thoughts.net/writing/against-sql (found from HN a week or so ago)
Every expression represents a filter of some kind.
In SQL (and in relational algebra), every expression represents a dataset.
That means composing SQL expressions is composing data, not composing operations on data.
Since there is a somewhat low, backwards-compatible barrier to entry to build a combinator language on top of SQL (Pine is an example), whether or not trading the increased learning curve of using combinators for better composability is a good idea can stand the test of time.
[1]: https://github.com/pine-lang/pine [2]: https://stedolan.github.io/jq/
SELECT
sd1.sale_person_id,
sd1.sale_person_name,
sd1.no_products_sold,
sd1.commission_percentage,
sd1.sales_department
FROM
sales_department_details sd1
INNER JOIN (
SELECT
sale_person_id,
MAX(no_products_sold) AS no_products_sold
FROM sales_department_details
GROUP BY sale_person_id
) sd2
ON
sd1.sale_person_id = sd2.sale_person_id
AND sd1.no_products_sold = sd2.no_products_sold; WITH max_sold_per_id AS (
SELECT
sale_person_id,
MAX(no_products_sold) AS no_products_sold
FROM sales_department_details
GROUP BY sale_person_id
)
SELECT
sd1.sale_person_id,
sd1.sale_person_name,
sd1.no_products_sold,
sd1.commission_percentage,
sd1.sales_department
FROM
sales_department_details AS sd1
INNER JOIN max_sold_per AS sd2
ON
sd1.sale_person_id = sd2.sale_person_id
AND sd1.no_products_sold = sd2.no_products_sold;
Which still isn't nice to "bang out" in an exploratory analysis. Especially because the thinking goes "Get the max sales numbers and associated IDs, and then add the meta data", but the code is still "with the meta data, join the max sales data" regardless whether you prepare the max sales data "at the top" (which I did) or in the join (as OP did)In dplyr, which imho has a nice syntax (but tons of other problems) it would be:
sales_department_details %>%
group_by(sale_person_id) %>%
filter(no_products_sold == max(no_products_sold)) %>%
select(
sale_person_id,
sale_person_name,
no_products_sold,
commission_percentage,
sales_department
)
First we group by ID, then on each group, we filter for the maximum sales, and finally we select the columns we are interested in. Super easy to bang out (and probably inefficient as we are moving tons of unnecessary columns between statements, but that is not the syntax fault)I think it is a remarkably well designed language. I often get decent results for minimal effort. It isn't something I use day to day but more often month to month and I generally forget what I learned a couple of years ago.
For example, I wanted to clear down some records for a defunct client from our backup results database. I started by using SELECT to reliably find the customer (not as simple as it might sound). Then I construct an INNER JOIN (in this case most joins are the same) to link to the jobs. A SELECT COUNT(*) experiment looks about right. I snapshot the VM and change my experiment to a DELETE.
SQL is a bit strange but it lends itself to experimentation ... to results, way better than any other language I know.
Then you get into functions and views and the like. SQL has just enough complication for whatever job you have at hand and no more.
I recently ran up a query in Icinga2 (Director) against a MariaDB and it seemed to write itself. I get far fewer syntax errors in SQL than anything else that I try to abuse!
root > people, # "root" keyword starts the document
person > person, # maps table context to a node
.age > @age, # @ maps a column to an attribute node
.first_name > name/first, # maps a column to a node
.last_name > .../last, # ... reuses the previous node's path
account.person_id +> person.person_id, # +> performs an INNER JOIN
account > account, # context is now "account" node
.id > @id, # account id attribute
^, # pop stack to previous table context
address > address, # switch context to "address" node
.*, # glob remaining columns
; # Denotes optional WHERE clause
The query produces: <people>
<person age="42">
<name>
<first>Charles</first>
<last>Goldfarb</last>
</name>
<account id="123"/>
<address>
<id>456</id>
<street>123 Query Lane</street>
<city>San Francisco</city>
</address>
</person>
</people>
It wouldn't take much to make that a JSON document.2) SQL statement syntax should start with the table specification so you can get autocompletion help when doing the columns and other expressions. The INSERT statement has it right, while SELECTs suck because the columns are specified before the WHERE clause, so there is no context. At least provide alternate syntaxes like SELECT FROM <table> COLUMNS <cols> WHERE <whereclause>, it would be minimal for the DB vendors to support.
3) SQL standards have been too nice to vendors, especially Oracle. The lack of portable SQL between databases has hamstrung the industry.
4) Stored procedure standards should have been formalized, as should standard apis. JDBC/ODBC were ok, but why are programming languages doing major enhancements/de facto standards setting?
The Department of Defense was asked by Congress to answer “Where does the money go?” and tried to use OWL and SPARQL queries across all the relational databases they owned but they couldn’t get it to work.
I can’t help but think something along those lines could present as a ‘low code’ data tool.
You can accomplish something similar with views, foreign tables, stored procedures, user defined functions, and other mechanisms which are common in databases like PostgreSQL, Microsoft SQL, etc.
I find PostgreSQL pretty handy because it supports embedded data structures such as lists in columns, supports queries over JSON documents in columns, etc.
My favorite DB for side projects is ArangoDB which uses collections of JSON objects like tables and the obvious algebra over them which lets you query and update like the best relational dbs but you don’t have the programmability of views, stored procedures, etc.
I think you are pretty familiar with those technologies. Do you think they have any value?
That is, it will defeat any technology that you bring to the table.
My own feelings about RDF are mixed. On one hand I've accomplished quite a few things with it, for instance, developing a technique for bringing multiple schema systems (say EMOF, XML Schema, and FIX Orchestra) into a single framework but it has been like
https://supernatural.fandom.com/wiki/Binb%C5%8Dgami
for me in that I have put huge amounts of time and money into it with very little return, not because of technical problems per se but because of problems marketing it.
There's a certain kind of stupidity inside the community that keeps it from making tools that are truly effective but there is even more stupidity outside the community that makes it seem it won't ever be understood. The semantic web seems to be cursed that it will never develop a brand like GraphQL, Docker, mongodb, or "FAANG" that works like a Jedi mind trick to bring people into its domains.
For instance I saw GraphQL as beneath contempt for many years because there was no specification, it was just "Facebook will return any answers that further their business interests if and when they want to" and somehow people are seduced by that the same way that they are seduced by Donald Trump or will cut out their left eyeball because Matt Butts said that is how to raise your PageRank by 0.1% next Thursday.
- MDX: created by Microsoft to provide a dimensional query language. The language is incredibly powerful, but depends on your understanding of dimensional modeling (go read Kimball is the best starting point for learning MDX). There are several tools, both commercial and open source, which implement an MDX interface to data.
- DAX: Microsoft's attempt to make MDX more approachable. A relational, functional language built on top of an in-memory columnstore relational storage engine, and used in several Microsoft products (Power BI, Analysis Services Tabular mode).
- Qlik has its own expression language whose name I am not sure of.
- Looker has LookML
There are a lot of BI tools out there. Not all have an expression language to support reusable measures/calculations, but many do. You may want to look into one.
If you think of SQL as a general-purpose query language, these BI-centric languages are DSLs for analytical queries. They are most useful for workloads where you have many queries that all use the same data model and are reasonably served by a pre-defined set of calculations/metrics.
[0] Do not mistake me, good data modeling is important for SQL as well.
SQL isn't as broken as you think, it does what it's supposed to do very well. There are many ways to work with SQL such as procedural SQL and ORMs that build on it.
---
Exist 2 major ways to solve this: You do a transpiler (like most ORM are, actually) or you go deeper and fix from the base.
The second could yield much better results. It will sound weird at first, but not exist anything that block the idea of "a SQL" language work for make the full app, with UI and all that.
SQL as-is is just too limited, in some unfortunate ways even for the use-case of have a restricted language usable for ad-hoc queries, but that is purely incidental.
The relational model is much more expressive than array, functional models (because well, it can supersede/integrate both) and with some extra adjustment you can get something like python/ML that could become super-productive.
Check out stored procedures and views.
Here's a great summary: https://stackoverflow.com/a/5195020
The information you seek above is computed and therefore justifies a view table instead of a "real one", because you really are doing something "complex". after that you can always select yourdata from yourview and you should be fine.
Relational data can only be really efficient if its relational and sometimes, computed tables are also a nice thing to have but even better: sometimes a porgramm needs to aggregate the data periodically and put it into the database relationally.
SELECT
sale_person_id,
max(no_products_sold) as max_sold,
link(sale_person_name, max_sold),
FROM sales_department_details
I'm not sure what `link` is supposed to be, but wouldn't the dream syntax modification to SQL simply be SELECT
sale_person_id,
no_products_sold as max_sold,
sale_person_name, commission_percentage, sales_department,
FROM sales_department_details
GROUP BY sale_person_id
WHERE no_products_sold = max(no_products_sold)On the other hand, maybe the time is ripe for you to "graduate" to using Datalog via other kind of databases, like Datomic, XTDB (fka Crux) and the likes (DataScript, Datalevin, etc)
Of course knowing Datalog won't help you with your SQL issues, but you can look into changing jobs, if you like what you see or maybe do some ETL job to spill over some data into the mentioned DBs and see whether querying it with Datalog is any better.
We already had the best minds in the world to try and replace sql, but because sql is rooted in group theory and math is hard to budge they all eventually had to get back and implement the group bys and havings and whatnot that complicate the sql syntax, except tackled on and with their proprietary syntax.
Tables are the unit of abstraction.
You’re on the right track with your instinct that you should be able to pull repeated work into a reusable unit. In many DB systems you can just register these sub queries as views and treat them as real tables. In the ETL world that I’m typically working in, you go one step further and just write pipelines to make useful intermediate tables.
Reuse tables, not subqueries.
select this,count(*) from that group by this
which is the most common data exploration query of them all which makes you type ‘this’ twice. select this, count(*) from that group by 1 SELECT
name, count(1)
FROM
(VALUES ('Kev',12), ('Meg', 14), ('Kev', 14))
people(name, age)
GROUP BY
1
Produces: [[Kev, 2], [Meg, 1]].But I don't get it. Could someone explain how this works?
CREATE MACRO count_values(this, that) WITH DEFINITION
SELECT this,COUNT(*) FROM that GROUP BY thisI disagree that it needs "help", which suggests that there is something fundamentally wrong with SQL that needs to change, possibly with help from outside of the SQL community.
On the contrary, I think SQL is great, but it could always be better.
Thus, if you need abstraction, you probably are doing it wrong already.
I also don't understand how does "SQL lacks meaningful abstraction". Most of serious RDBMSes have user-defined functions and stored procedures, that's just the ORM enthusiasts who are unwilling to use them.
I can think of so many other ways of dereferencing column names, from using a map/or lookup table to using types.
For example, selecting the unique id of a table regardless of what its name is.
In the same vein that different languages provide higher-level abstractions for machine code or JVM bytecode.
There are so many different ways to abstract aspects for different goals.
https://www.edgedb.com/ https://www.edgedb.com/showcase/edgeql
the specifics of an inner join vs outer join vs left join etc are crucial though. It makes sense to be able to specify them.
Because you are forced to specify what you want to SELECT before the FROM, you are left guessing the column names.
In contrast, in a programming language or ORM, you'd do something like (pseudocode) Entity.Select( ... ) and can get suggestions of the fields, but with SQL you are forced to do it backwards.
By "autocomplete" do you mean like column/table names ?
Some people put these inside strings though.. Like this:
https://www.w3schools.com/php/php_mysql_select.asp
(good practice arguments aside), Its a non trivial problem to solve across all languages.
Like dynamic SQL? That has its own problems.
Rather than trying to extend SQL I think that people should stop trying to use SQL/RDBMSs for every task.
Of course it's a bit painful and error prone, given SQL is a textual language, but as HoneySQL (https://github.com/seancorfield/honeysql) shows, you can represent SQL statements as data and generate them programmatically in a safe manner. I think it's compatible with https://babashka.org/ so you don't need a full Java environment to use it.
But first, SQL is a descriptive language: You describe what you want, you don't describe how you want it.
Instead, you rely on extremely complicated optimisers and a lot of using `EXPLAIN` to see what's happening under the hood. This is fundamental in the very _point_ of SQL.
Keeping that in mind, what do you mean:
[1] You feel the general notion of doing relational queries using a descriptive language is just broken. In which case, the fact that so many 'simpler' systems decided to add SQL support instead of just relying on the fact that folks will program their way into efficient queries is telling. People like being able to do this.
[2] You think the general notion is great, just, SQL specifically is badly designed. This then breaks down into two explanations.
[2a] You haven't actually read the spec, specifically your DB engine's spec. There's a ton DB engines can do - you can make your own procedures, your own aggregator functions, add triggers, and use VIEWs to combine it all (and VIEWs can act entirely as tables, including letting you INSERT or UPDATE them). For example, I'm pretty sure you can do precisely what you want, or at least get quite close, by only adding a little bit of extra definitions in postgresql. Either you just don't know enough (I'm just guessing here, based on very little info, please don't take it personally), or you do, but you find all that 'needlessly complicated'. In which case I think you're just misjudging how varied (and therefore complicated) your average DB user's needs are. Add the ability to do everything you want, but then for all use cases of people like you, and it is so complicated, you yourself would say 'yeah but not so complicated', and we're right back where we started.
[2b] No you really do know your way around SQL, including all the various exotic features that DB engines, particularly really good ones like psql, offer. And it's not good enough and you think you have a good grasp on how to make SQL specifically better. In which case: That has been done. Multiple times. The XKCD with the 14 standards comes to mind. Here is a REALLY long list of query languages: https://en.wikipedia.org/wiki/Query_language - pick your poison.
But first, think about the fact you didn't know about any of these. Whatever you're planning to 'replace' or 'fix' SQL, isn't that just doomed to be the 19th entry on that wikipedia list, just as forgotten as all the others?
In which case, [A] many, many db engines have extra syntax you might want to look at. You can make recursive queries, windowing functions, define your own procedures, and more - and use VIEWs to let you do precisely what you want. I'm pretty sure you can do precisely what you desire with postgres, using only a fairly simplistic amount of