Chapter6 ER模型

Chapter 6 The Entity-Relationship Model

ER diagram

Entity Sets(实体集,实体型)

一张学生表是一个实体集,一个学生是一个实体(一行记录)

Relationship Sets(关系集)

选课表就是一个关系集。它定义了“学生”和“课程”之间的“选修”这种关系。关系表示特定实体之间的一次具体关联。它对应的是联系表中的一行记录。 关系集也可以拥有自己的属性关系集属性),用于描述关系的特征。它同样对应联系表中的列。选课表这个关系集可以有成绩、选修日期等属性,这些属性不属于学生,也不属于课程,而是属于“选修”这个行为本身。

Choice of Primary key for Binary Relationship

在多的那一端把一的主键拿过来当外键

多元联系(non-binary)

三元Ternary Relationship 先转成多个二元联系再转表:将其他实体集的主键和关系自身属性建成表,各实体集不存放多余属性。

E-R图(概念设计结果)

Representing Cardinality Constraints in ER Diagram

→:一 —:多 (one,many) x (one,many) = 4 种

一对一

参与约束(Participant Constraints)

完全参与、部分参与

逻辑设计阶段

E-R图转关系模式 实体、联系、属性(单值属性、多值属性、复合属性)如何转表? 多值属性单独转表 复合属性拆开(如时间、地址)

弱实体集、强实体集; 用实体还是属性? Not to use the primary-key of an entity set as an attributes of another entity set (to represent implicitly association between these two entity sets), it is better to use an relationship set to explicitly show this association e.g. for the entity student, do not use instructor.id as its attribute, in stead of, representing association among student and instructor using relationship advisor.

用实体还是关系?“动作”对应“联系”

弱实体集

弱实体集理解

例子

扩展ER (详情看ISA那篇)

面向对象ER:Object-oriented (OO) E-R

specialization (特化,特殊化,例化) 自上而下,底层实体集是高层实体集的真子集 高层:超类;底层:子类

generalization (概括化,泛化,普遍化) 自底向上

attributes inheritance (属性继承) 联系也可以继承

Aggregation

relationship on relationship(联系的联系)

ER图记号总结

记号 记号(续) 替代记号 替代记号(续)

Built with Hugo
Theme Stack designed by Jimmy