gpt4 book ai didi

uml - 什么是 UML 中的一元关联

转载 作者:行者123 更新时间:2023-12-05 02:32:45 27 4
gpt4 key购买 nike

当我用谷歌搜索了解一元关联时,我得到了以下两个解释:

第一个是:

A unary relationship is when both participants in the relationship arethe same entity. For Example: Subjects may be prerequisites for othersubjects, or one employee manages many Employees.

第二个是:

Class B knows about ClassA.

Class A does not know about ClassB.

Now lets look at the following example:

You can see the Person and Address relationship below. We call thisrelationship as has-a relationship since person has a address. SoPerson knows the address but address does not know anything aboutperson

我是不是误会了什么?

最佳答案

通用语言

arity关联的数量是关于关联了多少个类。这是一个模棱两可的概念,因为一些人理解不同的类,而另一些人理解实例。

当应用于一元时,第一种解释表示自反关联(或自关联,即与 iteself 关联的类),而第二种解释表示不关联任何类(不是很有用: 任何类都可以与其他任何东西相关联)。

UML 透视图

幸运的是,UML 规范比通用语言精确得多:

An Association specifies a semantic relationship that can occur between typed instances. It has at least two memberEnds represented by Properties, each of which has the type of the end. More than one end of the Association may have the same type.

所以在 UML 中没有“一元关联”。它是二进制、三元或 n 元(规范中使用的术语)。对于两端具有相同类的二进制关联,UML 中没有专门的术语。但是reflexive或自联想是比一元更受欢迎的术语。

E/R 建模

术语“一元”在 entity-relationship modeling 的上下文中很流行, 描述关系数据库中的关系。关系或多或少对应于 UML 中的关联,实体对应于类,但存在一些细微的语义差异。 E/R 的基础是 set theory .如果一个关系是在相同的实体之间,这意味着实际上只涉及一个集合。这可能是一元在这种情况下更受欢迎的原因。

关于uml - 什么是 UML 中的一元关联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71157638/

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