Chapter 5: Entity-Relationship Model
Chapter 5: Entity-Relationship Model
• binary relationship
• involve two entity sets (or degree two).
• most relationship sets in a database system are binary.
• Relationships between more than two entity sets are
rare. Most relationships are binary. (More on this later.)
Example: students work on research projects under the
guidance of an instructor.
relationship proj_guide is a ternary relationship between
instructor, student, and project
Attributes
• An entity is represented by a set of attributes, that is
descriptive properties possessed by all members of an
entity set.
• Example:
instructor has attributes (ID, name, street, city, salary )
course has attributes (course_id, title, credits)
• Domain – the set of permitted values for each attribute
• Attribute types:
• Simple and composite attributes.
• Single-valued and multivalued attributes
• Example: multivalued attribute: phone_numbers
• Derived attributes
• Can be computed from other attributes
• Example: age, given date_of_birth
Composite Attributes
Mapping Cardinality Constraints
• A weak entity set becomes a table that includes a column for the
primary key of the identifying strong entity set
advisor(s_id, i_id)
Representing Relationship Sets (Cont.)
Many-to-one and one-to-many relationship sets that are total
on the many-side can be represented by adding an extra
attribute to the “many” side, containing the primary key of the
“one” side
Example: add an attribute dept_name to the schema arising
from entity set instructor
Total
Aggregation
Consider the ternary relationship proj_guide, which we saw
earlier
Suppose we want to record evaluations of a student by a
guide on a project
Aggregation (Cont.)
• Relationship sets eval_for and proj_guide represent
overlapping information
• Every eval_for relationship corresponds to a proj_guide
relationship
• However, some proj_guide relationships may not correspond to
any eval_for relationships
• So we can’t discard the proj_guide relationship
• Eliminate this redundancy via aggregation
• Treat relationship as an abstract entity
• Allows relationships between relationships
• Abstraction of relationship into new entity
Aggregation (Cont.)
• Without introducing redundancy, the following diagram
represents:
• A student is guided by a particular instructor on a particular project
• A student, instructor, project combination may have an associated
evaluation
Representing Specialization via Relational
Schemas
• Method 1:
• Form a relational schema for the higher-level entity
• Form a schema for each lower-level entity set, include
primary key of higher-level entity set and local attributes
schema attributes
person ID, name, street, city
student ID, tot_cred
employee ID, salary