| > SQL is a declarative language for working with relational databases. No. First and foremost, SQL is for tablational databases. A relation and a table are similar, to be fair, but have some key differences: - A relation is an unordered set of tuples. SQL opts for an ordered list of tuples (a table) instead. - A relation has no concept of NULL. A table does. - The implications of those differences also bring a whole bunch of other differences that further divide SQL from the relational model. SQL's only association to relational databases is in its name, being originally SEQUEL which was a play on QUEL – a language actually for relational databases that was a direct adaptation of Alpha from Codd's original paper. > The concept of composability doesn’t apply. Of course it does. Why wouldn't it apply? Datalog, a declarative language for querying data, is in many ways similar to SQL and it supports composition just fine. Many of the compile-to-SQL languages also support composition just fine. SQL could be composable. It should be composable. It just, because it still desperately clings to its COBOL-era glory days, is too afraid to add support. > In 40+ years programming SQL 40+ years of working with SQL and you are still this confused about it...? |
SQL the language does not require or describe ordering in tables — that happens as a side-effect of the physical implementation. No one should rely on ordering of table rows.
> A relation has no concept of NULL. A table does.
Null values occur in relations as soon as you write outer joins. All modern RDBMSs also allow defining nullable columns in base tables, and SQL allows/supports NULLs in that context, but with a little work one can eliminate nullable columns in base tables (we’ve already left pure relational land talking about base tables). But you cannot eliminate nulls from query results if you use outer joins.