简体   繁体   English

在EER(扩展ER图)中,实体可以有多个子类吗?

[英]In the EER(Extended ER Diagram), can entity have more than one subclasses?

In the question I'm doing at the moment gave two confusing sentences: 在我现在所做的问题中,给出了两个令人困惑的句子:

1. A property can be either be a house or an apartment. For a house it records ..bula bula
   For an apartment, it records .. bula bula

2. A property can be either for sale or rent, or for both. If a property is for sale, it 
   records .. bula bula. If the property is for rent, it records .. bula bula

These two are in the same question. 这两个是同一个问题。 Do I have to represent it by using subclasses or how? 我是否必须通过使用子类或如何表示它?

Many thanks. 非常感谢。

Yes, a entity can have multiple subclasses and multiple superclasses. 是的,一个实体可以有多个子类和多个超类。 Both faculty staff and student assistants may be subclasses of employees, and a student assistant may be a subclass of both employees and students. 教职员工和学生助理都可以是员工的子类,学生助理可以是员工和学生的子类。

You can create a Property entity with four subclasses, House, Appartment, PropertyForRent and PropertyForSale. 您可以创建一个包含四个子类的Property实体,House,Appartment,PropertyForRent和PropertyForSale。

A property may not be both a house and an appartment. 房产可能不是房子和公寓。 Therefore, use a circle with a d in it to indicate that it is disjoint. 因此,使用带有d的圆圈表示它是不相交的。 A property may be both for rent and for sale. 房产可以是出租和​​出售。 Use a circle with an o in it to indicate that it may overlap. 使用带有o的圆圈表示它可能重叠。

EER图中的不相交关系

This is described on page 443 in Advanced Data Modelling , and another example can be found on page 30 of this presentation . 高级数据建模中的第443页对此进行了描述,另一个示例可以在本演示文稿的第30页找到。

Sjoerd's answer is correct. Sjoerd的回答是正确的。

ER modeling tells you how to diagram subclasses, but it doesn't tell you how to implement them. ER建模告诉您如何绘制子类图,但它没有告诉您如何实现它们。 Nor should it. 也不应该。

If you are interested in designing SQL tables that implement subclasses, look up these topics, or their tags in SO: 如果您对设计实现子类的SQL表感兴趣,请在SO中查找这些主题或其标记:

Single Table Inheritance
Class Table Inheritance
Shared Primary Key

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

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