使用UML表示法的ER图和UML类图之间有什么区别? [英] What is the difference between ER Diagram using UML notation and UML Class Diagrams?

查看:585
本文介绍了使用UML表示法的ER图和UML类图之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,要求我创建UML类图.我在同一项目中的先前任务中得到的是使用UML表示法的ERD.同样值得注意的是,该项目与数据库有关,并且其中没有太多的编码,因此基于其他编码创建类图可能不是这里的主要目标.

I have a project which requires me to create a UML Class Diagram. What I have from the previous tasks in the same project is an ERD using UML notation. Also worth noting, this project is related to database and does not have much coding in it, so creating a class diagram based on other coding is probably not the main objective here.

我尝试了谷歌搜索如何将erd转换为类图".但是所有搜索结果仅显示了如何使用Crow's Feet表示法将ERD转换为UML类图.

I tried Googling "how to convert erd to class diagram" but all the search result only shows how to convert ERD using Crow's Feet notation into UML Class Diagram.

我还用Google搜索了有关UML表示法ERD的信息,发现

I also Googled about UML notation ERD, and found this site which said,

在UML表示法中,实体被建模为具有实体构造型的类".

In UML notation, entities are modeled as a "class" with an Entity stereotype.

这是否意味着使用UML表示法的ERD与UML类图相同?如果没有,有什么区别?

Does that mean that ERD using UML notation is the same with UML Class Diagram? If not, what are the differences?

注意:我知道关于ERD和类图之间的区别已经存在疑问,但是我专门问有关ERD 使用UML表示法的问题.

Note: I know there are already questions regarding difference between ERD and Class Diagram, but I am asking specifically about ERD using UML notation.

推荐答案

在Chen的原始

In Chen's original ERD notation attributes are ovals connected to their entity which is represented with rectangles, which can have relationships represented with losanges. This resulted in very large and complex diagrams, due to the many attributes.

Crow's Feet表示法因此变得更加流行,因为它允许以更紧凑的方式表示相同的模型,将属性及其实体分组在矩形中,并使用基数的直观可视表示形式.但是,既然UML是建模者的Lingua Franca,那么诱使人们去寻找其他选择.

Crow's Feet notation became therefore more popular since it allowed to express the same models in a more compact way, grouping attributes together with their entity in the rectangles, and using an intuitive visual representation of cardinality. But now that UML is the Lingua Franca of modellers, it's tempting to look at other alternatives.

您的

Your linked source suggests a very natural mapping of the core ERD concepts of entity, attribute, relationships, into the UML class, properties and associations:

(...)实体被建模为具有实体构造型的类".

(...) entities are modeled as a "class" with an Entity stereotype.

(...)属性可以以方框样式(...)排列

(...) attributes can be arranged in a box style (...)

关系显示为连接两个实体的单条实线.沿线显示了最小和最大基数,并且可以添加动词短语以完全表征关系的性质.

Relationships are shown as a single solid line connecting the two entities. The minimum and maximum cardinalities are shown along the line and verb phrases can be added to completely characterize the nature of the relationship.

实际上,UML中最适合ERD图的表示法是类图.

And indeed, the most suitable notation for an ERD diagram in UML would be a class diagram.

但是要注意细微的语义差异.例如:

    在UML中,
  • 任何属性(与映射相关的属性)都可以在框内(称为属性)建模,也可以与相关的关联类(称为实体)建模,关联结束.

  • in UML any property (what your mapping relates to attribute) could be modelled either within the box (as what you call an attribute) or as a related associated class (as what you call an entity) with an owned association end.

UML类应该具有行为(这是由于底层的OOP概念所致).UML阅读器可能会误认为拥有无行为的类是错误的设计(贫血的领域模型).«Entity»构造型不足以消除歧义,因为它通常在UML上下文中与实体控制边界范式,它也期望实体具有行为.也许您使用不太含糊的原型(例如«Data-Entity»

UML classes are expected to have behavior (it's because of the underlying OOP concepts). Having classes without behavior can be misunderstood by UML reader as a bad design (anaemic domain model). The «Entity» stereotype is not sufficient to disambiguate, since it's in general associated in the UML context with the Entity-Control-Boundary paradigm, which also expects entities to have behavior. Maybe you define an UML profile using a less ambiguous stereotype such as «Data-Entity»

您的链接源对UML中的鱼尾纹易位产生误导:您可以在UML中的关联上添加动词短语,但在关联的中间可以加上箭头紧靠文字旁边以显示阅读方向.在UML中,关联端的文本是完全不同的:称为角色".ERD图中的等效项将是在另一端的实体中包含一个带有角色名称的属性(并且该属性将与标识另一个实体的主键相对应).

Your linked source is misleading about Crow's feet transposition in UML: you can add a verb phrase on an association in UML, but in the middle oc the association and with and with an arrow head next to the text to show the direction of the reading. In UML, the text at an association end is something completely different: it's called "role". The equivalent in an ERD diagram would be to include an attribute with the role name in the entity at the other end (and which would correspond the the primary key identifying the other entity).

可以在有关ERD的维基百科文章.

在更普通的文章" 用于将结构化分析和设计工件转换为UML的框架 "":它还提到了

A mapping algorithm is proposed in a more general article "A framework for transforming structured analysis and design artifacts to UML": it mentions that in addition, ERD diagrams sub-type relations should be transformed in UML generalization under the condition that it's an IsA relation.

这篇关于使用UML表示法的ER图和UML类图之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆