database 不相交和重叠的设计约束

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19920998/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 09:07:10  来源:igfitidea点击:

disjoint and overlapping design constraints

database

提问by FinalJon

I'm really confused on the difference between disjoint and overlapping design constraints in relational databases. I've looked around, but have had a hard time finding an understandable example. Could someone please explain this to me via an example?

我真的很困惑关系数据库中不相交和重叠设计约束之间的区别。我环顾四周,但很难找到一个可以理解的例子。有人可以通过一个例子向我解释这一点吗?

Thanks!

谢谢!

回答by Justin R Roberts

Say you have a super class 'musician' then two sub classes 'singer' and 'guitar player'.

假设您有一个超级类“音乐家”,然后有两个子类“歌手”和“吉他手”。

In a disjoint constraint you would have to put the musician in either one or the other sub classes. In an overlapping constraint the musician can be put in both.

在不相交的约束中,您必须将音乐家放在一个或其他子类中。在重叠约束中,音乐家可以同时放在两者中。

回答by pblead26

Let's say you have a super class 'account' with sub classes 'Savings Account' and 'Current Account'. This is a disjoint constraint situation because a bank account can either be Savings or Current. It cant be both at the same time.

假设您有一个带有子类“储蓄帐户”和“活期帐户”的超类“帐户”。这是一种不相交的约束情况,因为银行账户可以是 Savings 或 Current。不能同时是两者。

For an overlapping constraint situation, let's say we have a super class 'Person' and subclasses 'Customer' and 'Employee'. In this case, a person can be Customer and Employee both. Therefore, overlapping.

对于重叠约束情况,假设我们有一个超类“Person”和子类“Customer”和“Employee”。在这种情况下,一个人既可以是客户,也可以是员工。因此,重叠。

回答by Ragulan

The disjoint rule states an entity instance of a supertype can only be a member of one subtype. The overlap rule states an entity instance of a supertype can be a member of multiple subtypes.

不相交规则规定超类型的实体实例只能是一个子类型的成员。重叠规则规定超类型的实体实例可以是多个子类型的成员。

Example of disjoint rule:Instance of Super-typeAnimalcan only be member of exactly one of these Sub-typesbeing Panda,Cheetahand DogDisjoint Union, (An animal can either be Panda or be Dog or be Cheetah but can't be any two or more at the same time)

不相交的规则的实施例:的实例超级型动物只能是这些中的正好一个成员的子类型熊猫,猎豹不交联,(动物可以是熊猫或是狗或是猎豹但不能是任何两个或更多同时)

Example of overlap rule:Instance of Super-typePersoncan be member of multiple Sub-typesbeing Woman,Driverand EngineerOverlapping Union, (A person can be a Woman and that same Woman can be Driver and that same Woman can be Engineer at the same time)

重叠规则的例子:的实例超级型可以是多个的构件的子类型女人,驱动程序工程师重叠联盟,(一个人可以是一个女人和同一女子可以是驱动器,并且同样的妇女可以是在工程师同时)

回答by Prakhar Sethi

Let's simplify this confusing concept. First of all, understand that there is a discriminator between subtype and supertype. If the value of a discriminator is not null and appears in supertype entity instance then that must be linked with the only one subtype. This is called disjoint constraint.

让我们简化这个令人困惑的概念。首先,了解子类型和超类型之间有一个鉴别器。如果鉴别器的值不为空并且出现在超类型实体实例中,那么它必须与唯一的一个子类型相关联。这称为不相交约束。

For example, you say in school a person can be teacher and student but a teacher can't be a student and vice versa. Then in person supertype and (student, teacher) subtype exists a discriminator called person_type. If person_type in person entity is 't' then it is linked with teacher subtype only not with a student. Similarly, we can write it for the student.

例如,你说在学校里,一个人可以是老师和学生,但老师不能是学生,反之亦然。然后在person超类型和(学生,教师)子类型中存在一个称为person_type的鉴别器。如果 person_type 在 person 实体中是 't' 那么它只与教师子类型相关联,而不与学生相关联。同样,我们可以为学生编写它。

Now, in overlapping constraint, the supertype entity instance can appear in many subtype instance.

现在,在重叠约束中,超类型实体实例可以出现在许多子类型实例中。

In overlapping example consider a teacher can be a student also. Then 't' can be linked with student and teacher subtype entity.

在重叠示例中,请考虑教师也可以是学生。然后“t”可以与学生和教师子类型实体链接。

回答by Haris Mehmood

suppose Member is super class and its two sub-classes one is student and 2nd one is faculty,if(Member) of subclass(student or faculty)not both then it is disjoint. if member both of its subclass then it non-disjoint or overlapping.

假设 Member 是超类,它的两个子类一个是学生,第二个是教师,如果子类(学生或教师)的(成员)不是两者,那么它是不相交的。如果它的两个子类都是成员,那么它就不会不相交或重叠。

.

.