如何表达“无信息”?在关系代数中? [英] How to express "no information" in relational algebra?

查看:113
本文介绍了如何表达“无信息”?在关系代数中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力学习关系代数的一项任务是要求我找到想要免费租用房地产或未提供有关愿意支付多少费用的信息的客户。该表如下所示:

A task that I'm working on to learn relational algebra is asking me to find the clients who want to rent a property for free, or have not given information about how much they are willing to pay. the table looks like this:

Client(clientNo,firstName,lastName,maxRent)

Client(clientNo, firstName, lastName, maxRent)

我遇到了一些麻烦找到有关如何表示信息不足或空数据点的任何信息..到目前为止,我已经提出了其中一半表达式是伪代码的方法:

I have some trouble finding any information about how to represent a lack of information, or an empty data point.. so far I've come up with this where half of the expression is psuedo code:

σmaxRent = 0或[未提供任何信息](客户端)

σ maxRent = 0 OR [no info given] (Client)

推荐答案

此表中有哪些行?不知道该如何回答?

What rows go in this table? How can we answer without knowing that? How can anyone query without knowing that?

假设您的表中包含以下行:名为[firstname] [lastname]的client [clientid]愿意支付[maxrent]的行。如果特定客户既没有第一名又没有第二名姓,那么此表中没有行。您无法使用它回答您的查询。如果他们确实有第一名&姓氏,但您不知道它们,则无法设置表格-无法继续-该表格不适合您。进一步假设我们拥有所有客户名称。但是,如果我们不知道他们愿意支付什么,我们同样无法进行。

Suppose your table holds the rows where "client [clientid] named [firstname] [lastname] is willing to pay [maxrent]". If a particular client doesn't have both a first & last name then there is no row for them in this table. You can't answer your query with it. If they do have first & last names but you don't know them then you can't set the table--you can't proceed--this table is not for you. Let's further suppose we have all client names. But we similarly can't proceed if we don't know what they are willing to pay.

假设您的表中包含以[cent [clientid] ] [姓氏]表示愿意支付[maxrent]。然后,您可以将其用于提供最高租金的客户。但是它无法为其他客户记录任何内容。但是,如果您还有一个表,其中包含名为[firstname] [lastname]的client [clientid]的行,但未说出他们愿意支付的价格,则可以为所有客户记录。因此,您可以回答您的查询。

Suppose your table holds the rows where "clent [clientid] named [firstname] [lastname] has said they are willing to pay [maxrent]". Then you can use it for clients who have given maximum rent. But it can't record anything for other clients. However if you also had a table holding the rows for "client [clientid] named [firstname] [lastname] has not said what they are willing to pay" then you could record for all clients. So you could answer your query.

假设您的表包含以下行,其中名为[firstname] [lastname]的cilent [clientid]表示他们愿意支付[ maxrent]或没有说他们愿意支付多少,[maxrent] ='xxx'。如果您有客户的ID&名称,但他们没有说出愿意支付的价格,那么就会有一行显示maxrent = xxx。然后,您可以编写查询-您的 [未提供任何信息]表示maxrent ='xxx'。

Suppose your table holds the rows where "cilent [clientid] named [firstname] [lastname] has either said they are willing to pay [maxrent] or has not said how much they are willing to pay and [maxrent]='xxx'". If you have a client's id & names but they haven't said what they are willing to pay then there is a row for them with maxrent='xxx'. Then you can write your query--your "[no info given]" means maxrent='xxx'.

假设我们有两个表,而不是该表, [clientid]被命名为[firstname] [lastname]& 客户[clientid]愿意支付[maxrent]。然后,您的表在其含义下就是对这些新表在其含义下的某种查询。每个新表都可以用旧表来表示。在一种设计中,查询之间存在简单的对应关系。一个在另一个。因此,我们可以编写您的查询。

Suppose instead of that table we have two tables, "client [clientid] is named [firstname] [lastname]" & "client [clientid] is willing to pay [maxrent]". Then your table under its meaning is a certain query of those new tables under their meanings. And each of the new tables can be expressed in terms of the old. There is a simple correspondence between a query in one design & one in the other. So we can write your query.

在SQL中,传统做法是使用NULL作为特殊值,而不是 xxx。该表的含义为名为[firstname] [lastname]的客户端[clientid]表示他们愿意支付[maxrent]或没有说他们愿意支付多少,并且[maxrent]为NULL。 SQL中的运算符特别对待NULL -它们与具有相同名称的关系运算符或日常运算符不同。

In SQL the tradition is to use NULL as a special value instead of 'xxx'. The table meaning would be "client [clientid] named [firstname] [lastname] has either said they are willing to pay [maxrent] or has not said how much they are willing to pay and [maxrent] is NULL". Operators in SQL treat NULL specially--they aren't the same operators as the relational or everyday ones with the same names.

请注意,无NULL设计具有更多的含义但更简单的基本表和意义。任何带有NULL的设计都可以重新排列为无。所有这四个设计都可以重新排列为其他任何形式。还有其他样式的无NULL设计与具有NULL的设计更相似。

Notice that the NULL-free designs have more but simpler base tables & meanings. Any design with NULL can be rearranged to one without. All four of these designs can be rearranged to any other. There are other styles of NULL-free designs that are more similar to designs with NULL.

(肯定是从您的表中提取的某些教科书允许maxrent为NULL。他们也从来没有清楚地说过表中的行。但是我们的想法是,每个可以包含NULL的表的含义都是明显的无空含义的明显转变。他们错误地&模糊地说:没有空,有必要引入错误的数据来表示这种状态,或者添加可能对用户没有意义的其他属性。他们还说了很多典型的模糊无用的东西,例如空不是值。)

(A certain textbook that your table is surely drawn from allows maxrent to be NULL. They also never clearly say what rows go in their tables. But the idea is that every table that can have NULLs has a meaning that is the obvious transformation of the obvious null-free meaning. They wrongly & fuzzily say, "Without nulls, it becomes necessary to introduce false data to represent this state or to add additional attributes that may not be meaningful to the user." They also say a lot of typical fuzzy unhelpful things like "null is not a value".)

(尚不清楚未知信息或表达未知或空数据点是什么意思。人们可以表达那个不知道满足条件的值,但是表中的每一行都根据其含义断言该语句,而其中的每一行都不具有(适当的)类型)声明根据其含义做出的否定语句。)

(It's not clear what you mean by "unknown information" or by "expressing" something that is not known or "an empty data point". One can express that one doesn't know the value(s) satisfying a condition. But every row in a table asserts the statement made from its meaning and every row not in it (of the appropriate type) asserts the negation of the statement made from its meaning.)

Re关系查询。

在建模和规范化时如何处理空值?

这篇关于如何表达“无信息”?在关系代数中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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