如何在UML中建模用户之间的自我阻止关系?

huangapple go评论53阅读模式
英文:

How to model a self-blocking relationship between users in UML?

问题

我正在开发一个用户管理系统,我需要对用户之间的自我屏蔽关系进行建模。用户应该有能力屏蔽自己。我正在使用UML来表示我的系统的类和关系。我目前有一个代表系统中用户的User类。现在,我需要引入用户能够屏蔽自己的概念。我该如何在UML中表示这种关系?

如何在UML中建模用户之间的自我阻止关系?

我考虑用户应该与自己建立关系,这是否会产生一个新的类叫做BlockedUser?

英文:

I am working on a user management system, and I need to model a self-blocking relationship between users. A user should have the ability to block themselves. I'm using UML to represent my system's classes and relationships. I currently have a User class that represents a user in the system. Now, I need to introduce the concept of a user being able to block themselves. How can I represent this relationship in UML?

如何在UML中建模用户之间的自我阻止关系?

i'm thinking that a user should have a relation ship with him self user and that should produce a new class called BlockedUser ??

答案1

得分: 1

你已经接近成功了:在User之间添加一个自关联,命名为blocking(你可以将一端标记为blocked,另一端标记为blocked by),并在两端都使用多重性*

即使您可能希望在使用关系数据库管理系统(RDBMS)实现这个设计时添加一个额外的表,但您不需要添加一个额外的类。

如果您想要为每个封锁添加更多信息,例如开始日期、封锁原因,甚至结束日期,您可以将自关联变成一个关联类(从关联边的中间点到具有与关联名称相同的名称的类的虚线)。

英文:

You're almost there: add a self-association between User, name it blocking (you may label one end blocked and the other blocked by) and use multiplicity * at both ends.

You do not need an additional class, even if you might want an additional table if you'd implement this design with an RDBMS.

If you want to add more information to each blockage, for example the start date, the reason for blockage and, why not, an end date, you may make the self association an association class (dotted line from the middle of the association edge to a class that has the same name as the association).

huangapple
  • 本文由 发表于 2023年5月30日 07:26:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76360803.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定