使用逆关系两次?
我想知道我是否可以对 2 个不同的关系使用相同的逆关系两次?
下面是一个示例:
Trip
起点(一对一关系)MapPoint(逆ReferencedBy)
目的地(一对一关系)MapPoint(逆向ReferencedBy) ReferencedBy)
MapPoint
- ReferencedBy (对多关系) Trip (这里就有问题了,逆如何设置?)
I would like to know if I can use the same inverse relationship twice for 2 different relationships?
Here is an example :
Trip
Origin (to-one relationship) MapPoint (inverse ReferencedBy)
Destination (to-one relationship) MapPoint (inverse ReferencedBy)
MapPoint
- ReferencedBy (to-many relationship) Trip (here is the problem, how to set the inverse ?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,你不能或不应该。我尝试过,但它会造成混乱。
所以 MapPoint 应该有 2 个关系。
按来源引用
ReferencedByDestination
乍一看可能看起来很奇怪。但想一想。这种做法并没有什么问题。
另一种方法是建立从 MapPoint 到起点和终点的一对多关系并放置一个枚举。
这种方法更优雅,但实际上要复杂得多。
另一种方法是有 2 个子实体:出发地和目的地。
这个更优雅,但您仍然需要
在 MapPoint 中使用。
No you can't or shouldn't. I tried and it causes mayhem.
So that MapPoint should have 2 relationship.
ReferencedByOrigin
ReferencedByDestination
It may look strange at first. But think about it. There is nothing wrong with this approach.
Another approach is to have a one to many relationship from MapPoint to Origin and Destination and put an enum.
This approach is more elegant but actually far more complicated.
Another approach is to have 2 subEntities of Origin and Destination.
This one is more elegant but still you will need
in the MapPoint.