An Edit Mistake
I miswrote:
qandrreturns the same results under the condition that the schema was as given
should be
qandrreturns the same results under the condition that the schema and data was as given
I think an earlier version of the draft did use data.
Yes and no. Under a strict schema regime, you would not have data that do not fit the schema. But as you say:
On The Concrete Steps Listed
Your concrete steps (1,2,3,4) are very very excellent and specific elaborations/examples of the table of compositions process I listed above. I have some comments:
A key thing I feel that has been slightly missed is that the @cascade directive or ~ are actually elements of the query language, and thus can be boiled down to an operation. I do think this is jumping to solutions before a blueprint is even created (e.g. the table of compositions)
On Denotational Semantics
That’s what the whole denotational semantics shebang is all about. You can only make a rewrite if you know that the result of the rewrite will yield the same data (same denotation).
The main issue is you run into “runtime” issues, requiring you to look at the data before you look at the data. Enforcing a strict schema would allow you to avoid doing that, so you look at the metadata (schema) before you look at the data.
On the Suitability of a Query Planner for DQL
I think the flexibility of the query specifically allows for a query planner to be written! Other than directives (which are “action” words, or “commands” if you are used to 1960s style PLT lingo), everything else is declarative. That leaves a LOT of freedom to re-order the operations to something that best fits the performance characteristics. A key is to lean on Codd’s relational algebra, or to create something similar.
On @normalize
My understanding is @normalize is just a fmap. It’s just an operation.