gpt4 book ai didi

mysql - SQL中基数的定义是什么

转载 作者:可可西里 更新时间:2023-11-01 06:28:16 24 4
gpt4 key购买 nike

我的课本Database Systems基数定义如下:

The cardinality of a relation is the number of tuples it contains. By contrast, the number of tuples is called the cardinality of the relation and this changes as tuples are added or deleted. High-cardinality - many tuples, low-cardinality - few tuples.

虽然关于 Cardinality (SQL statements) 的维基百科文章, 定义如下:

Cardinality refers to the uniqueness of data values contained in a particular column (attribute) of a database table. The lower the cardinality, the more duplicated elements in a column. There are 3 types of cardinality: high-cardinality, normal-cardinality, and low-cardinality.

他们可能都是对的,但我不能将这两个定义联系起来作为相关定义。重新措辞将适用!

最佳答案

他们说的是同一件事,这与元组(关系代数)或行(外行术语)有关。

当它说高基数时,特定属性(或字段)的可能值是唯一的,因此行数或元组数更高:

示例:

 StudentID   Lastname Firstname  Gender
101 Smith John M
102 Jones James M
103 Mayo Ann F
104 Jones George M
105 Smith Suse F

StudentID 而言,cardinalityhigh 因为它是唯一的。其中有五 (5) 个元组/行。

另一方面,姓氏 具有正常的基数,特别是只有三 (3) 个唯一的元组/行。因此它具有正常基数

最后,Gender 只有两个可能的唯一元组,因此 Low Cardinality

您可能会将此处的 Cardinality 与关系的 Degree 混淆,后者与关系中的 attributes/fields 的数量有关(或表格)。

另一方面,Database 的教科书在谈到 Cardinality 时,通常与一个实体与另一个实体的关系有关,即可能关系的数量参与给定关系类型的实体的出现。因此,例如对于 binary relationship cardinality 可以是one-to-oneone-to-many多对多

关于mysql - SQL中基数的定义是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25548029/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com