简体   繁体   English

建模或关系?

[英]modeling OR relationships?

How do you trasnlate OR relationships in ER diagrams? 您如何在ER图中转换OR关系? For example, you have 2 entities that have some connection with the third, but only one of them can have that relation?(ex. BussinessOwner or PrivateOwner can hold just one Property ) ? 例如,您有2个实体与第三个实体有某种联系,但是只有其中一个实体可以具有这种关系?(例如, BussinessOwnerPrivateOwner只能拥有一个Property )?

Option 1 (easier): Two nullable foreign keys, BusinessOwnerID and PrivateOwnerID. 选项1(更轻松):两个可为空的外键,BusinessOwnerID和PrivateOwnerID。

Option 2 (more normalized): Both BusinessOwner and PrivateOwner are Owners, so you could make an Owner entity with whatever information is common between BusinessOwner and PrivateOwner. 选项2(更规范化):BusinessOwner和PrivateOwner都是所有者,因此您可以使用在BusinessOwner和PrivateOwner之间共有的任何信息来创建Owner实体。 Then add an OwnerID to both the BusinessOwner and PrivateOwner tables. 然后将OwnerID添加到BusinessOwner和PrivateOwner表中。

User an owner and Type Field. 用户ownerType字段。 Not 2 owner Fields. 不是2个所有者字段。

Owners are People entity. 所有者是人实体。 Types are Type entity or strings ("Business" Owner or "Private Owner") 类型是类型实体或字符串(“业务”所有者或“私人所有者”)

What if you add a new type... "Sr. Partner" With your model you would have to add new filed and recode your business rules. 如果添加新类型,该怎么办...“高级合作伙伴”对于您的模型,您将必须添加新的字段并重新编码您的业务规则。

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

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