数据库系统笔记
二、The Relational Model of Data
Declaring keys
- primary key:主键所对应的列的值是唯一的且不允许为NULL,不会重复。例如,学生信息表中的学号(ID)可以被声明为主键,从而保证每个学生都有唯一的学号。每个表只能有一个主键。主键可以由一个或多个列组成(组合主键),但在一个表中不能定义多个主键。
- Unique:唯一约束的列也必须是唯一的,每行数据的唯一约束值不能重复,但可以有NULL。一个表中可以有多个唯一约束,即可以在多个列上定义 Unique 约束。
四、Entity-Relationship Model
Three principal element types:
- Entity sets: An entity is an abstract object of some sort , and
a collection of similar entities forms an entity set. - Attributes: Properties of the entities in that set.
- Relationships: Connections among two or more entities sets.
An E/R diagram is a graph representing entity sets, attributes,
and relationships.
- Entity sets are represented by rectangles.
- Attributes are represented by ovals.
- Relationships are represented by diamonds.
- Edges connect an entity set to its attributes and also connect a relationship to its entity sets.
如果一个实体集E中的每一个成员都能通过关系R联系最多一个F中的成员,那么我们称在关系R中E和F是多对一的。
If R is both many-one from E to F and many-one from F to E , then we say that R is one-one.
If R is neither many-one from E to F or F to E ,then we say R is many-many.

**Subclass in the E/R model **
We connect an entity set to its subclass using a relationship called isa (i.e. “A is a B”), represented as a triangle.
Every isa relationship is one-one, although we shall not draw the two arrows that are associated with other one-one relationships.
A subclass has its own attributes apart from the attributes of its superclass.

Constrains in the E/R Modle

