术语“元组”是什么意思? 在关系数据库中意味着什么?
请解释一下sql中的元组是什么意思?谢谢..
Please explain what is meant by tuples in sql?Thanks..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
请解释一下sql中的元组是什么意思?谢谢..
Please explain what is meant by tuples in sql?Thanks..
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(10)
这里的大多数答案都是正确的。 但是,行不是元组。 元组
*
是带有名称的已知值的无序集合。 因此,以下元组是相同的东西(我使用虚构的元组语法,因为关系元组很大程度上是一个理论构造):...当然假设 x、y 和 z 都是整数。 另请注意,不存在“重复”元组之类的东西。 因此,以上不仅是相同的,而且是相同的东西。 最后,元组只能包含已知值(因此不能包含空值)。
行
**
是具有名称的已知或未知值的有序集合(尽管它们可以被省略)。 因此,以下比较在 SQL 中返回 false:但请注意,有一些方法可以“伪造”它。 例如,考虑这个 INSERT 语句:
假设 x 是第一个,y 是第二个,z 是第三个,这个查询可以重写如下:
或者这样:
...but all we're real所做的是改变顺序而不是删除它。
另请注意,也可能存在未知值。 因此,您可能会有具有未知值的行:
...但请注意,此比较将始终产生
UNKNOWN
。 毕竟,您如何知道两个未知值是否相等?最后,行可能会重复。 换句话说,
(1, 2)
和(1, 2)
可能比较相等,但这并不一定意味着它们是同一件事。如果这是您感兴趣的主题,我强烈建议您阅读 SQL 和关系理论:如何由 CJ Date 编写准确的 SQL 代码。
*
请注意,我谈论的是关系模型中存在的元组,这与一般的数学有点不同。**
以防万一您想知道,SQL 中的所有内容都是行或表。 因此,(1, 2)
是一行,而VALUES (1, 2)
是一个表(一行)。更新:我在博客文章中对此答案进行了一些扩展此处。
Most of the answers here are on the right track. However, a row is not a tuple. Tuples
*
are unordered sets of known values with names. Thus, the following tuples are the same thing (I'm using an imaginary tuple syntax since a relational tuple is largely a theoretical construct):...assuming of course that x, y, and z are all integers. Also note that there is no such thing as a "duplicate" tuple. Thus, not only are the above equal, they're the same thing. Lastly, tuples can only contain known values (thus, no nulls).
A row
**
is an ordered set of known or unknown values with names (although they may be omitted). Therefore, the following comparisons return false in SQL:Note that there are ways to "fake it" though. For example, consider this
INSERT
statement:Assuming that x is first, y is second, and z is third, this query may be rewritten like this:
Or this:
...but all we're really doing is changing the ordering rather than removing it.
And also note that there may be unknown values as well. Thus, you may have rows with unknown values:
...but note that this comparison will always yield
UNKNOWN
. After all, how can you know whether two unknown values are equal?And lastly, rows may be duplicated. In other words,
(1, 2)
and(1, 2)
may compare to be equal, but that doesn't necessarily mean that they're the same thing.If this is a subject that interests you, I'd highly recommend reading SQL and Relational Theory: How to Write Accurate SQL Code by CJ Date.
*
Note that I'm talking about tuples as they exist in the relational model, which is a bit different from mathematics in general.**
And just in case you're wondering, just about everything in SQL is a row or table. Therefore,(1, 2)
is a row, whileVALUES (1, 2)
is a table (with one row).UPDATE: I've expanded a little bit on this answer in a blog post here.
它是一个缩短的“
N 元组
”(如四元组
、五元组
等),它是作为一个整体的行集的一行。
如果您发出:
,整个结果将是一个
ROWSET
,并且每对col1,col2
将是一个元组
。有些数据库可以将元组作为一个整体来使用。
例如,您可以执行以下操作:
,它检查一个
rowset
中的整个tuple
是否与另一个rowset
中的整个tuple
匹配代码>.It's a shortened "
N-tuple
" (like inquadruple
,quintuple
etc.)It's a row of a rowset taken as a whole.
If you issue:
, whole result will be a
ROWSET
, and each pair ofcol1, col2
will be atuple
.Some databases can work with a tuple as a whole.
Like, you can do this:
, which checks that a whole
tuple
from onerowset
matches a wholetuple
from anotherrowset
.在关系数据库中,表是关系 (数学意义)。 关系是元组的集合。 因此关系数据库中的表行是关系中的元组。
维基百科关于关系:
In relational databases, tables are relations (in mathematical meaning). Relations are sets of tuples. Thus table row in relational database is tuple in relation.
Wiki on relations:
无论其在数学中的用途如何,RDBMS 中的元组通常被视为表或结果集中的一行。在 RDBMS 中,元组是无序的。 MDDBMS 中的元组是单元格中的数据实例及其关联的维度实例(成员)。
列族数据存储中的元组是什么?
Whatever its use in mathematics, a tuple in RDBMS is commonly considered to be a row in a table or result set. In an RDBMS a tuple is unordered. A tuple in an MDDBMS is the instance of data in a cell with its associated dimension instances (members).
What is the tuple in a column family data store?
元组 = 1 条记录; n-tuple = 'n' 条记录的有序列表; Elmasri Navathe 书(第 198 页,第 3 版)。
记录 = 有序或无序。
tuple = 1 record; n-tuple = ordered list of 'n' records; Elmasri Navathe book (page 198 3rd edition).
record = either ordered or unordered.
据我了解,表有一组 K 个键和一个具有域 K 的打字函数 T。表的一行或“元组”是具有域 K 的函数 r,使得 r(k) 是 T 的元素(k) 对于每个密钥 k。 因此,该术语具有误导性,因为“元组”实际上更像是关联数组。
As I understand it a table has a set K of keys and a typing function T with domain K. A row, or "tuple", of the table is a function r with domain K such that r(k) is an element of T(k) for each key k. So the terminology is misleading in that a "tuple" is really more like an associative array.
数据库表中的行
row from a database table
元组用于引用关系数据库模型中的行。 但元组与行几乎没有什么区别。
Tuple is used to refer to a row in a relational database model. But tuple has little bit difference with row.
元组用于定义多维数据集中的数据切片; 它由一个或多个维度的一个成员的有序集合组成。 元组用于标识多维数据集中的多维数据的特定部分; 由多维数据集中每个维度的一个成员组成的元组完整地描述了一个单元格值。
A tuple is used to define a slice of data from a cube; it is composed of an ordered collection of one member from one or more dimensions. A tuple is used to identify specific sections of multidimensional data from a cube; a tuple composed of one member from each dimension in a cube completely describes a cell value.