On 2007-12-19, at 15:44, David King wrote:
{select,[random,'()','*',count],
        {from,bar},
        {where,{id,'=',5}}}

That kind of wrapper around SQL can be useful, but it doesn't actually do anything about the hate that is SQL. The big problem with the SQL select statement is that it's a horizontal syntax. "select columns", "select rows", "join", "sort", "group", "store", and so on are separate operations. The classical SQL select statement is like a horizontal microcode operation that has five slots: the first is "select columns", the second contains "select rows" combined with "join", then there's a "sort", a "group" and a second "select rows" by itself hanging on the end in the "having" clause.

So you take these and build a tree of subclauses, and pass it to the database engine, that if it's any good breaks it down into a simpler tree that treats "select foo from (select * from something where bar) as a where zot" and "select foo from something where bar having zot" as the same thing. And it's not like they didn't have Lisp back then.

Reply via email to