简体   繁体   English

多对多关系稍微复杂一些

[英]slightly more complicated many-to-many relationship

I have a single table that has 2 many-to-many relationships to another table. 我有一个表,该表与另一个表有2个多对多关系。 Eg: 例如:

main
====
id
leftOptions
rightOptions

options
=======
id
option

I need to connect both leftOptions and rightOptions to the options table, so I can't make the usual junction table, with mainId and optionsId as keys. 我需要将leftOptions和rightOptions都连接到选项表,因此我无法使用mainId和optionsId作为键来创建通常的联结表。

Also, I'm using mysql, so I'd need something that works with that software. 另外,我正在使用mysql,因此我需要与该软件一起使用的东西。

TIA TIA

I see two ways: 我看到两种方式:

main        mainToOptions        options
====        ============         =======
id          mainId               id
            optionId             option
            isLeft

Or 要么

main        mainToLeftOptions       mainToRightOptions       options
====        =================       ==================       =======
id          mainId                  mainId                   id
            optionId                optionId                 option

However, it's really hard to say which one you should choose without a bigger picture, 但是,很难说,如果没有更广阔的前景,应该选择哪一个,

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

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