班级图与实体关系图(关系和基数)

发布于 2025-01-25 07:17:13 字数 47 浏览 2 评论 0原文

UML类图中的关联和聚集的多样性与关系数据库中关系的基础性相同(实体关系图)吗?

Are the multiplicities of associations and aggregations in an UML class diagram the same as the cardinalities of the relationships in a relational database (Entity-Relationship Diagram)?

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

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

发布评论

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

评论(1

等你爱我 2025-02-01 07:17:13

简而言之

,UML中多重性的概念与ERD中的基数相同。主要区别是术语。

首先,我们需要牢记

UML 2.5.1规格解释了第33页

集合的 基数 是该集合中包含的值数量。多重性的 多重性 指定其代表的集合的有效基础性。 多样性是对基数的限制 ,它不得小于下限的下限,也不大于为多重性指定的上限(除非多重性是无限的,在这种情况下,上限没有限制)。

简而言之,此处的集合是指链接到另一类给定实例的类的实例。因此,UML定义说多重性定义了在此类集合的允许大小上存在的约束。

有趣的是, peter chen> peter chen 他的第一篇论文。陈说“ 映射类型 1:11:nn:m,并解释说:

有关 的信息通过在图中指定“ 1”,“ M”,“ N”表示。


我们必须小心术语。在这里, entity 是指某些属性的一组特定值,即一个实例,而 entity Setity Setity 是指我们通俗地称为“实体”的所有可能实例”。

总之,ERD和UML的措辞可能略有不同,但是在这两种情况下,有关一侧实例数的限制可能与另一侧的实例有关。

In short

Yes, the concept of multiplicity in UML is the same than cardinality in ERD. The main difference is the terminology.

Demonstration

First of all, we need to keep in mind the original meaning of cardinality, which means the number of elements in a given set.

The UML 2.5.1 specifications explain page 33 that

The cardinality of a collection is the number of values contained in that collection. The multiplicity of a MultiplicityElement specifies valid cardinalities of the collection it represents. The multiplicity is a constraint on the cardinality, which shall not be less than the lower bound and not greater than the upper bound specified for the multiplicity (unless the multiplicity is unlimited, in which case there is no constraint on the upper bound).

To make it short, the collection here refers to the instances of a class that are linked to a given instance of another class. So the UML definition says that the multiplicity defines the constraints that exist on the allowed size of such sets.

Interestingly, Peter Chen, the inventor of the ER model does not mention at all cardinality in his first papers. Chen speaks of "mapping types 1:1, 1:n and n:m and explains that:

Information about the number of entities in each entity set which is allowed in a relationship set, is indicated by specifying "1","m","n" in the diagram.

We have to be careful about the terminology. Here, the entity refers to a specific set of values for some attributes, i.e. an instance, whereas the entity set refers to all the possible instances of what we colloquially call "entity".

In conclusion, the wording of ERD and UML might be slightly different, but in both cases, it is about constraints regarding the number of instances on one side may be related to instances on the other side.

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