没有属性的关系

发布于 2024-07-24 07:27:48 字数 234 浏览 10 评论 0原文

Aheo 询问是否是 可以设置一个只有一列的表格。 没有列的关系怎么样,或者考虑到这在大多数现代“关系”DBMS 中似乎很难做到,没有属性的关系怎么样?

Aheo asks if it is ok to have a table with just one column. How about one with no columns, or, given that this seems difficult to do in most modern "relational" DBMSes, a relation with no attributes?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

So要识趣 2024-07-31 07:27:48

恰好存在两种没有属性的关系,一种具有空元组,一种不具有空元组。 在第三宣言中,Date 和 Darwen(某种程度上)幽默地将它们命名为 TABLE_DEE 和 TABLE_DUM (分别)。

它们的有用之处在于它们是各种关系运算符的恒等式,扮演着相当于普通代数中的 1 和 0 的角色。

There are exactly two relations with no attributes, one with an empty tuple, and one without. In The Third Manifesto, Date and Darwen (somewhat) humorously name them TABLE_DEE and TABLE_DUM (respectively).

They are useful to the extent that they are the identity of a variety of relational operators, playing roles equivalent to 1 and 0 in ordinary algebra.

夜清冷一曲。 2024-07-31 07:27:48

具有单列的表是一个集合 - 只要您不关心对值进行排序,或将任何其他信息与它们相关联,它看起来就很好。 您可以检查其会员资格,基本上这就是您所能做的。 (如果您对单列没有 UNIQUE 约束,我想您也可以计算出现次数......多重集)。

但是,没有列的表(或没有属性的关系)意味着什么?或者,它有什么好处?!

A table with a single column is a set -- as long as you don't care about ordering the values, or associating any other info with them, it seems fine. You can check for membership in it, and basically that's all you can do. (If you don't have a UNIQUE constraint on the single column I guess you could also count number of occurrences... a multiset).

But what in blazes would a table with no columns (or a relation with no attributes) mean -- or, how would it be any good?!

水溶 2024-07-31 07:27:48

DEE 和笛卡尔积形成一个幺半群。 实际上,如果您有 Date 的关系汇总运算符,您可以使用 DEE 作为分组关系来获取总计。 还有许多其他 DEE 实用的示例,例如,在具有二元连接运算符的功能设置中,您将得到 n-ary join =foldr join dee

DEE and cartesian product form a monoid. In practice, if you have Date's relational summarize operator, you'd use DEE as your grouping relation to obtain grand-totals. There are many other examples where DEE is practically useful, e.g. in a functional setting with a binary join operator you'd get n-ary join = foldr join dee

半边脸i 2024-07-31 07:27:48

“恰好有两种没有属性的关系,一种有空元组,一种没有。在《第三宣言》中,Date 和 Darwen(有点)幽默地分别将它们命名为 TABLE_DEE 和 TABLE_DUM。

它们的用处在于它们各种关系运算符的恒等式,起到相当于普通代数中1和0的作用。”

当然,它们也扮演着布尔代数中“TRUE”和“FALSE”的角色。 这意味着当诸如“商店开门”和“警报已设置”之类的命题要在数据库中表示时,它们非常有用。

这样做的结果是,它们还可以有效地用于关系代数的任何表达式中,因为它们具有“充当 IF/ELSE”的属性:加入 TABLE_DUM 意味着根本不保留其他参数的元组,加入 TABLE_DEE 意味着保留它们全部。 因此,将 R 连接到可以等于 TABLE_DEE 或 TABLE_DUM 的相关变量 S,RA 相当于“if S then R else FI”,其中 FI 代表空关系。

"There are exactly two relations with no attributes, one with an empty tuple, and one without. In The Third Manifesto, Date and Darwen (somewhat) humorously name them TABLE_DEE and TABLE_DUM (respectively).

They are useful to the extent that they are the identity of a variety of relational operators, playing a roles equivalent to 1 and 0 in ordinary algebra."

And of course they also play the role of "TRUE" and "FALSE" in boolean algebra. Meaning that they are useful when propositions such as "The shop is open" and "The alarm is set" are to be represented in a database.

A consequence of this is that they can also be usefully employed in any expression of the relational algebra for their properties of "acting as an IF/ELSE" : joining to TABLE_DUM means retaining no tuples at all from the other argument, joining to TABLE_DEE means retaining them all. So joining R to a relvar S which can be equal to either TABLE_DEE or TABLE_DUM, is the RA equivalent of "if S then R else FI", with FI standing for the empty relation.

德意的啸 2024-07-31 07:27:48

嗯。 因此,缺乏“现实世界的例子”让我很困扰,我尽了最大努力。 也许令人惊讶的是,我已经成功了一半!

cjs=> CREATE TABLE D ();
CREATE TABLE
cjs=> SELECT COUNT (*) FROM D;
 count 
-------
     0
(1 row)

cjs=> INSERT INTO D () VALUES ();
ERROR:  syntax error at or near ")"
LINE 1: INSERT INTO D () VALUES ();

Hm. So the lack of "real-world examples" got to me, and I tried my best. Perhaps surprisingly, I got half way there!

cjs=> CREATE TABLE D ();
CREATE TABLE
cjs=> SELECT COUNT (*) FROM D;
 count 
-------
     0
(1 row)

cjs=> INSERT INTO D () VALUES ();
ERROR:  syntax error at or near ")"
LINE 1: INSERT INTO D () VALUES ();
马蹄踏│碎落叶 2024-07-31 07:27:48

具有单列的表对于简单的查找来说是有意义的。 假设您有一个要过滤用户输入文本的字符串列表。 该表将存储您想要过滤掉的单词。

A table with a single column would make sense as a simple lookup. Let's say you have a list of strings you want to filter against for user inputed text. That table would store the words you would want to filter out.

给不了的爱 2024-07-31 07:27:48

从 SQL 数据库的角度很难看出 TABLE_DEE 和 TABLE_DUM 的实用性。 毕竟,不能保证您最喜欢的数据库供应商允许您创建其中之一。

在关系代数中也很难看到 TABLE_DEE 和 TABLE_DUM 的实用性。 人们必须超越这一点。 为了让您了解这些常数如何变得生动,请考虑将关系代数放入适当的数学形状中,这尽可能接近布尔代数。 D&D代数A是朝这个方向迈出的一步。 然后,我们可以通过更基本的关系代数运算来表达经典的关系代数运算,这两个常数变得非常方便。

It is difficult to see utility of TABLE_DEE and TABLE_DUM from SQL Database perspective. After all it is not guaranteed that your favorite db vendor allows you creating one or the other.

It is also difficult to see utility of TABLE_DEE and TABLE_DUM in relational algebra. One have to look beyond that. To get you a flavor how these constants can come alive consider relational algebra put into proper mathematical shape, that is as close as it is possible to Boolean algebra. D&D Algebra A is a step in this direction. Then, one can express classic relational algebra operations via more fundamental ones and those two constants become really handy.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文