When you dig into it, the powerful idea here is the relational algebra, and its equivalence to a first-orderish logic.
I put up with SQL so I can use relations, and I love Postgres because it has the least bad SQL (by a mile!)
As you've said, the basic motivation behind SQL is the relational
algebra from the branch of mathematics called "naive set theory".
SQL does that really well. Late Dr. Ted Codd was a mathematician,
so he was also aware of non-naive set theory so the "selection
language" of Zermelo's axiom of choice was also included. That is
why we are selecting elements of subsets and not defining subsets.
Codd was also working for IBM, once great company, whose name
stands for "It's Better Manually". IBM was doing lots of business
with the banks (figures) so the transaction handling part was
modeled after the banking business. When I've had my first course
in SQL, back in 1988, I was given analogy with writing checks: I A
writes a $100 check to B, one of the following two things can
happen: either A has enough money to cover the check, in which
case B will have $100 more in his account and A will have $100
less or, if the transaction doesn't go through, nothing will
happen. Any mixed outcome in which B is $100 richer but A doesn't
have $100 less money in his account or A has $100 less money but B
is not $100 richer is strictly prohibited. That transaction must
happen atomically, as a whole or not happen at all. So, that's SQL
for you: relational algebra plus banking business. Relational
algebra implementation is rather good, although a tad too verbose.
Transactional part is excellent and still reflects the needs of
the business community today.
But SQL is a terrible, no good, very bad language.
I cannot accept such a religious persecution of SQL without a
detailed explanation.
I don’t really understand why folks who love the relational model aren’t perpetually up in arms about SQL being their only option. Much better query languages are known and well studied.
I’d love to see Postgres offer say Datalog. But until that Halcyon day, we could at least aggressively extend SQL to make it less awful.
It will take much more than a blog post to eradicate decades of
investment into SQL by both computer scientists and business
community. I've seen the same crusade against SQL on Slashdot and
I assume you were behind that as well. So, if I were you, I would
establish a company to implement Datalog language in a database
and try to sell that to the people. That happened in 1979: Larry
Ellison, Bob Miner and Ed Oates established a company and offered
a SQL product, competing with hierarchical databases like IMS and
CICS/DL1, to the world. The rest is history. I am sure that if you
do the same and if you are right about the Datalog, a brilliant
future is ahead of you. That is the way of the Force. Anything can
happen. A young student can come from Africa, convinced that he
can sell electric cars and be very successful while doing that.
So successful that he became the richest man in the world. I am
sure that your endeavor with Datalog will have similar success.
Market decides what is the standard. May the Force be with you. In
the mean time, I will still be using SQL.
-- Mladen Gogala Database Consultant Tel: (347) 321-1217 https://dbwhisperer.wordpress.com