客户与个人/组织之间的聚合关系
我有一个 Client 对象,其中包含 Person 对象或 Organization 对象。这些Person对象或Organization对象可能与独立于Client对象的其他对象有关系。在这种情况下,我应该在 Client -> > 之间使用通用聚合关联吗?人员
和客户->组织
,其中客户端对象是整体。
另请注意这些场景:
- 在某些场景中,人可能是一个普通的人; 人代表客户付款(*组织*)
- 人可能是客户产品。
- 人可能是供应商
I have a Client object which will either have a Person object or Organization object in it. These Person objects or Organization objects might have relations to other objects independent of the Client object. In this case should I use a General Aggregation association between Client -> Person
and Client -> Organization
where the Client object is the whole.
Also note these scenarios:
- Person might be a normal Person in some scenarios like; Person makes payment on behalf of Client(*Organization*)
- Person might be a Client which bought a Product from Us.
- Person might be a Supplier
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然您确实没有提供足够的信息,但听起来您正在描述一个典型的角色类模型。
我怀疑您的客户实际上并没有拥有个人或组织,而是该个人或组织是客户,或IOW,无论是个人还是组织在某种关系中可以扮演客户的角色。
有多种方法可以对此进行建模,但没有单一正确的解决方案。您可能会发现这篇文章很有帮助
While you really didn't provide enough information, it sounds like you're describing a typical Role Class Model.
I suspect that your Client doesn't really have a Person or an Organization, but rather that Person or an Organization is a Client, or IOW, either a Person or an Organization can play a role of a Client in a certain relationship.
There are various ways to model this, and no single correct solution. You might find this article helpful
不要忘记两个关联之间的异或约束(因为客户端不能同时连接到个人和组织)
don´t forget an xor constraint between both associations (since a client cannot be connected to both a person and a organization)