本文介绍了E2L:如何处理参与多重关系的外键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的数据库模型



FlowObject

FlowObjectID(PK)

说明

活动



ProcessObject

FlowObjectID(PK,FK)

HasSubmit



DecisionObject

FlowObjectID(PK,FK)

YesFlowObjectID(FK)

NoFlowObjectID(FK)

YesCaption

NoCaption




当我尝试使用创建我的实体模型时,我在我的项目中收到此警告。 >

外键约束FK_ProcessObject_FlowObject1已从存储模型中省略。表Investigations.Store.ProcessObject的列FlowObjectID是参与多个关系的外键。一对一的实体模型不能验证,因为数据不一致是可能的。





为什么它掉了我的外键?因为一对一的实体模型不能验证,因为数据不一致是可能的。



所以听起来好像是因为数据不一致而丢弃了FK但是放弃FK实际上会减少日期一致性?



我应该重新设计我的数据库吗?是否还有L2E处理参与多重关系的FK?是否认为FK参与多重关系是不好的数据库设计?

解决方案

你所描述的,翻译成object- FlowObject包含一个可选的ProcessObject和一个可选的DecisionObject。如果这是您实际意义的数据库模式是正确的。



如果您尝试使ProcessObject和DecisionObject扩展 FlowObject,则不一致是可能的,因为ProcessObject和DecisionObject行都可能存在。为了消除不一致,联合子类建模技术是合适的:只存在ProcessObject和DecisionObject表,每个包含所有相关的字段,而作为抽象基类的FlowObject将成为一个视图,该视图由两张桌子。


I have a Database model like this

FlowObject
FlowObjectID (PK)
Description
Active

ProcessObject
FlowObjectID (PK, FK)
HasSubmit

DecisionObject
FlowObjectID (PK, FK)
YesFlowObjectID (FK)
NoFlowObjectID (FK)
YesCaption
NoCaption

When I try and use create my Entity model I get this warning in my project.

Foreign Key constraint 'FK_ProcessObject_FlowObject1' has been omitted from the storage model. Column 'FlowObjectID' of table 'Investigations.Store.ProcessObject' is a Foreign Key participating in multiple relationships. A one-to-one Entity Model will not validate since data inconsistency is possible.

???

Why did it drop my foreign key? Because "A one-to-one Entity Model will not validate since data inconsistency is possible."

So it sounds like it is saying it dropped the FK because of data inconsistency but dropping the FK actually reduces date consistency?

Should I redesign my database? Is there anyway for L2E to handle FK's that participate in multiple relationships? Is it considered bad database design to have FK's that participate in multiple relationships?

解决方案

What you've described, translated to object-oriented terms, is that a FlowObject contains an optional ProcessObject and an optional DecisionObject. If this is what you actually meant, the database schema is correct.

If you're trying to have ProcessObject and DecisionObject extend FlowObject, inconsistency is possible because both the ProcessObject and DecisionObject rows may exist. To eliminate the inconsistency, the union-subclass modeling technique is appropriate: only ProcessObject and DecisionObject tables exist, each containing all relevant fields, and FlowObject, as an abstract base class, becomes a view consisting of the union of the common base fields between the two tables.

这篇关于E2L:如何处理参与多重关系的外键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 00:13