database 多重性与基数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17877582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Multiplicity vs Cardinality
提问by Sam Shiles
When talking about data models and databases, the term Cardinalityis often used to describe the number of allowed elements in a given set.
在谈论数据模型和数据库时,术语基数通常用于描述给定集合中允许的元素数量。
UML often refers to the same property as Multiplicity.
UML 通常引用与Multiplicity相同的属性。
Is there any differences between these two terms or are they synonymous?
这两个术语之间有什么区别还是它们是同义词?
采纳答案by Suleka_28
The simplest explanation would be to say:
Multiplicity = Cardinality + Participation
最简单的解释是:
多重性 = 基数 + 参与
Cardinality: Denotes the maximum number of possible relationship
occurrences in which a certain entity can participate in (in simple terms: at most).
基数:表示某个实体可以参与的最大可能关系发生次数(简单来说:最多)。
Participation: Denotes if all or only some entity occurrences participate in a relationship (in simple terms: at least).
参与:表示是否所有或仅某些实体出现参与关系(简单来说:至少)。
回答by LMeyer
Martin Fowler has talked about this subject on his website. Quoting :
Martin Fowler 在他的网站上谈到了这个主题。引用:
When data modeling methods talk about relationships, they use the term cardinality to indicate how many entities may be linked together. So you might have a relationship between order and customer and say that the cardinality of the relationship is one-to-many. Or you might hear that the cardinality of customers for an order is 0-to-many.
UML avoids the term cardinality preferring to use multiplicity. Often people with a data modeling background are surprised at this since cardinality has been so widely used in data modeling circles.
The reason for the change is that the dictionary definition of cardinality is "the number of elements in a particular set or other grouping" (OED). According to this the data modeling usage is actually wrong. In the excellent UML Reference Manual, Rumbaugh defines multiplicity as "A specification of the range of allowable cardinality values - the size - that a set may assume". The UML uses multiplicity in various places, for a property (association or attribute) and also to show the multiplicity of parts in a composite structure. It's formally defined as a lower and upper bound. An association (the UML equivalent to a relationship in data modeling circles) has a multiplicity for each direction.
当数据建模方法谈论关系时,他们使用术语基数来表示有多少实体可以链接在一起。因此,您可能会在订单和客户之间建立关系,并说这种关系的基数是一对多的。或者,您可能听说订单的客户基数是 0 对多。
UML 避免使用术语基数而更喜欢使用多重性。通常具有数据建模背景的人对此感到惊讶,因为基数在数据建模圈中得到了如此广泛的使用。
更改的原因是基数的字典定义是“特定集合或其他分组中的元素数”(OED)。据此,数据建模用法实际上是错误的。在优秀的 UML 参考手册中,Rumbaugh 将多重性定义为“允许基数值范围的规范 - 大小 - 一个集合可以假设”。UML 在不同地方使用多重性,用于属性(关联或属性),也用于显示复合结构中部件的多重性。它被正式定义为下限和上限。关联(UML 等同于数据建模圈中的关系)在每个方向上都具有多重性。
回答by Jim L.
Simply put: a multiplicityis made up of a lower and an upper cardinality. A cardinality is how many elements are in a set. Thus, a multiplicity tells you the minimum and maximum allowed members of the set. They are not synonymous.
简单地说:多重性由低基数和高基数组成。基数是一个集合中有多少个元素。因此,多重性告诉您集合中允许的最小和最大成员。它们不是同义词。
回答by Andrew
Thank you for the question and answers above.
谢谢你上面的问题和答案。
Really got confused with those terms this morning (coffee did not help).
今天早上真的对这些术语感到困惑(咖啡没有帮助)。
Given the example below:
鉴于以下示例:
0-1 ---------- 1-*
0-1 ---------- 1-*
Multiplicities:
多重性:
First multiplicity, for the left entity: 0-1
Second multiplicity, for the right entity: 1-*
第一个多重性,对于左实体:0-1
第二个多重性,对于正确的实体:1-*
Cardinalities for the first multiplicity:
第一个多重性的基数:
Lowercardinality: 0
Uppercardinality: 1
下基数:0
上基数:1
Cardinalities for the second multiplicity:
第二个多重性的基数:
Lowercardinality: 1
Uppercardinality: *
较低的基数:1
上基数:*
回答by Purushoth
A multiplicity of an event = Participation of an element + cardinality of an element.Participationmeans the least number of the occurrence of the entity in a specific relationship whereas Cardinalitymeans the maximum (upper bound)and the minimum (lower bound) number of occurrence of the specific entity in a relationship.
事件的多重性 = 元素的参与度 + 元素的基数。参与表示实体在特定关系中出现的最少次数,而基数表示特定实体在关系中出现的最大(上限)和最小(下限)次数。
回答by JATIN AHUJA
The Multiplicityis the constraint on the collection of the association objects whereas the Cardinalityis the count of the objects that are in collection.
在多重是对关联对象,而集合约束基数是在收集的对象的数量。
The multiplicity is actually the constraint on cardinality.
多重性实际上是对基数的约束。


