同一实体上的多对多关系,无需额外的连接表列
我有一个与其自身具有多对多关联的实体。
如果我需要一些额外的属性(例如这里询问) 答案是使用一个新的中间实体。但是如果没有它们,使用与实体本身的直接多对多关联是不好的做法吗?
I have an entity that has many-to-many association to itself.
If I needed some additional properties (like asked here) the answer would be to use a new intermediate entity. But without them is it bad practice to use direct many-to-many association to the entity itself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Aleksey,
如果您有其他列,您需要一个新的中间实体。
不,如果您愿意,您可以因为您在连接的表上没有其他列
Aleksey,
If you have additional columns, you need a new intermediate Entity.
No, you can if you want since you do not have additional columns on The joined Table
使用映射表是 N 到 N 关系的最佳方式,而无需在映射表本身中创建新列。
Using a mapping table is the optimal way for N to N relations without creating new columns in the mapped tables themselve.