UML类模型如何建立多对多关系 [英] UML class model how to model many to many relationship

查看:510
本文介绍了UML类模型如何建立多对多关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了一些有关UML模型应该包含什么以及不应该包含什么的教程.作为开发人员,我总是从关系数据模型的角度来思考,在这种关系数据模型中,表之间永远不可能有多对多的关系.现在,使用UML类模型,我已经读到,如果它们不提供附加值,则可以跳过链接表.

I have read several tutorials on what a UML model should contain and what not. As a developer I always think in terms of a relational data model where you could never have a many to many relationship between tables. Now with a UML class model, I've read that if they don't provide added value, you could just skip the linktables.

但是,我还阅读了一个教程,其中的示例使用表中的数据给出,并强烈建议在对类模型进行建模时将每个类描绘成一个简单的表.

However I've also read a tutorial where examples where given using data inside tables and was strongly suggesting to picture each class as a simple table while modeling your class model.

我很困惑,现在是什么?!

I am confused, what is it now?!

推荐答案

将其建模为M:N关系.与关系模型相同,在代码中将存在某种类型的关联类(或链接类).除非在联接属性之上具有属性,否则无需将其放在图表上(就像您通常会从ERD中省略联接实体,除非它具有相关实体中不是外键的属性).通常将链接类绘制为通过虚线连接到关系的类.

Model it as an M:N relationship. Same as in a relationship model there will be an associate class (or link class) of some kind in code. No need to put that on the diagram unless it has attributes on top of the join attributes (much like you would generally omit a join entity from an ERD unless it had attributes that weren't foreign keys in the related entities). The link class is typically drawn as a class connected to the relationship by a dashed line.

UML 2类图中,注册联接实体就是一个很好的例子.

The Enrolment join entity is a good example of this in UML 2 Class Diagrams.

这篇关于UML类模型如何建立多对多关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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