简体   繁体   English

同一实体上的多对多关系,而无需其他联接表列

[英]Many-to-many relationship on the same entity without additional join table columns

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? 但是,如果没有它们,对实体本身使用直接多对多关联是一种不好的做法吗?

使用映射表是N对N关系的最佳方法,而无需在映射表中自行创建新列。

Aleksey, 阿列克西

If you have additional columns, you need a new intermediate Entity . 如果您还有其他列,则需要一个新的中间Entity

But without them is it bad practice to use direct many-to-many association to the entity itself ? 但是,如果没有它们,对实体本身使用直接多对多关联是否是错误的做法?

No, you can if you want since you do not have additional columns on The joined Table 否,您可以根据需要进行操作, 因为联接表上没有其他列

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM