| Jesus. I feel there may be a touch of dunning-kruger about you. From that book (page xvi) "
Standard SQL is relationally complete in its support for declarative constraints by permitting the inclusion of query expressions in the CHECK clause of a constraint declaration. We do not yet know—and it is an important and interesting research
topic—how to do the kind of optimization that would be needed for the DBMS to work out
efficient evaluation strategies along the lines of the authors’ custom-written solutions.
" So it can't. But then you say. > But the reasons are ENTIRELY related to SQL's depending on 3VL. Easy to fix. Simply require the assertion to be defined on tables (ok, ok, relvars) with 'not null' on every column, also require a PK to ensure uniqueness, and you're away. Except you aren't. I'm not going to argue with you. Your knowledge is clearly considerable but it comes with something extra I don't need. |
That other snippet "Standard SQL is relationally complete ... CHECK clause ..." is technically correct, but the standard allows subqueries referencing other tables than the one the CHECK clause is on, but as far as I'm aware no product supports that (and the ones that do leave the user exposed to risk of faulty behaviour). Sadly, such a feature is necessary if we'd want to write, say, an FK constraint in the form of CHECK clause on the referencing table : CHECK (EXISTS (SELECT 1 FROM PARENT WHERE <FK equality tests here> ) ).