Expressing “is null” in Relational algebra

2019-01-29 06:03发布

问题:

In SQL, if I want to know whether an expression is NULL, I can use is null.

But I don't understand how I can express is null in relational algebra.

Can I use δ Field_Name=NULL(Table_Name)?

回答1:

There is no NULL in relational algebra. In SQL the operators treat the value NULL specially, syntactically and semantically, differently than other values, usually by returning NULL when comparing two values when one of them is NULL. So "=" in a WHERE is not equality, it is an operator like equality that acts differently for NULL. So SQL WHERE is not the same operator as algebraic RESTRICT.

If someone wants to use NULL with the relational algebra to set or query relation variables you have to get straight what operators they mean when they say things like "AND" and "=" (also relational operators like RESTRICT and PROJECT), and whether NULL is a value treated specially by them.

See also What to do with null values when modeling and normalizing?.