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

查看:37
本文介绍了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?!

推荐答案

关系链接表"是一种多对多关系的实现技术.

The "relational link table" is an implementation technique for a Many-to-Many relationship.

无论实施方式如何,这种关系都存在.

The relationship exists irrespective of how it's implemented.

在对象模型中,您有多种选择来实现多对多,这可能(也可能不)涉及额外的持久表.它可以通过很多不同的方式完成.

In an object model, you have many choices for how to implement many-to-many, which may (or may not) involve an additional persistent table. It could be done lots of different ways.

UML 的重点是能够描述模型真正的本质特征.

The point of UML is to be able to describe the essential features of what the model really is.

您可以描述实现.它们是具有不同目的的独立图表.您可以使用链接表轻松显示关系实现.您也可以在没有链接表的情况下显示基本模型.

You can also describe the implementation. They're separate diagrams with separate purposes. You can easily show the relational implementation with the link table. You can also show the essential model without the link table.

这是基本关系

这里是关系的实现

两者都是有效的 UML.真正的问题是你需要向其他人展示什么?"基本事实或一种特定实现?

Both are valid UML. The real question is "what do you need to show other people?" Essential truth or one particular implementation?

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

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