如何在 Java 中映射这个棘手的实体/关系模型?
我对 3 个实体之间的多对多关系有点困惑。我想知道我的对象模型是什么样子的。我有三个实体,A、B、C 和 A→B (M:N),并且 A 和 B 之间的关联表与另一个关联表链接,该关联表与第三个实体建立另一个 1:n 关系。我从未见过与另一个关联表建立 1:n 关系的这种关系。欲了解更多信息,请查看下图。
如果我谈论对象模型,那么我会说“INSTANCE_A”有许多“INSTANCE_B”实例,反之亦然,但我不知道如何总结“INSTANCE_C”的关系。
还请让我知道这三个实体之间的这种关系的定义是否正确?我的意思是关系设计有问题吗?
提前致谢
编辑:所有箭头表示(1:n或m:1)关系
I have little bit confusing many to many relationship between 3 entities. And i want to know how can be my object model look like. I have three Entities, A,B,C and A<->B (M:N) and associate table between both, A and B, is linked with another associate table which make another 1:n relationship with third entity. I have never seen such relationship which make 1:n relationship with another associate table. For further information please have look on following diagram.
If i talk about object model then i will say "INSTANCE_A" has many "INSTANCE_B" instance and vice versa but i do not know how can i summarize relationship for "INSTANCE_C".
Please also let me know whether definition of such relationship between all three entities is right ? i mean is there any problem in relationship design.
Thanks in advance
EDIT: All arrows denote (1:n or m:1) relationship
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
数据模型是正确的,但这些表的对象模型可能有点麻烦。我会做这样的事情:
在 ORM 中映射框架可能会变得很时髦。
The data model is correct, but the object model for these tables can be kind of trucky. I'd do something like this:
Mapping that in an ORM framework can get funky.
这将带你走向正确的方向。尝试设计一个UML图,或者ER应该也可以。这是一些带有模型的论文以及该模型的相应 Java 代码 http://www.csd.uoc.gr/~hy252/references/UML_for_Java_Programmers-Book.pdf。 (转到 -> 类图章节)。
This shall bring you into the right direction. Try to design a UML diagram, or ER should be ok too. Here is some paper with a Model and the corresponding Java-Code for this model http://www.csd.uoc.gr/~hy252/references/UML_for_Java_Programmers-Book.pdf. (Go to -> Class diagrams chapter).