Is it possible to express a not null constraint using relational calculus?

548 Views Asked by At

I understand that relational calculus is based on first order logic and as such has no concept of null values, however a not null constraint can be expressed in a query in relational algebra using an anti-join. Is there an equivalent mechanism to express such a query using only relational calculus?

For example, could a basic SQL query in the form: SELECT * from x WHERE y IS NOT NULL be expressed using relational calculus?

1

There are 1 best solutions below

0
On

E.F.Codd proposed introducing nulls to the relational model but he never seemed to deal with the consequences. In his book, "Relational Model for Database Management", he proposed using two different kinds of null and a four-value logic. He suggested such a system would need a tautology detection algorithm to make sure the right result (or at least a useful, comprehensible result) would be returned for some queries. It seems to me that such a scheme must be impractical and doomed to fail, although I have no proof. To me it seems unlikely that users would be able to understand tautology detection properly.

Under Codd's scheme, short circuit operations like x=x would presumably evaluate to true, even in the presence of nulls. The authors of SQL did not follow Codd's scheme of course, and there lies the difficulty. There is no single consistent set of rules for the treatment of nulls either in theory or in working software, so unless you explain such a system and its rules your question is unanswerable.