表示“为空"在关系代数 [英] Expressing "is null" in Relational algebra

查看:211
本文介绍了表示“为空"在关系代数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在SQL中,如果我想知道一个表达式是否为NULL,我可以使用is null.

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

但我不明白如何在关系代数中表达 is null.

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

我可以使用δ Field_Name=NULL(Table_Name)吗?

推荐答案

关系代数中没有 NULL.在 SQL 中,运算符在句法和语义上对值 NULL 进行特殊处理,与其他值不同,通常在比较两个值为 NULL 的两个值时返回 NULL.因此,WHERE 中的="不是相等,它是一个类似相等的运算符,对 NULL 的作用不同.所以 SQL WHERE 与代数 RESTRICT 不是同一个运算符.

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.

如果有人想在关系代数中使用 NULL 来设置或查询关系变量,当他们说AND"和="(以及 RESTRICT 和 PROJECT 等关系运算符)时,您必须弄清楚他们的意思是什么,以及NULL是否是他们特别处理的值.

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.

另请参阅建模和规范化时如何处理空值?.

这篇关于表示“为空"在关系代数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆