Chapter 7: Entity-Relationship Model
Chapter 7: Entity-Relationship Model
Chapter 7: Entity-Relationship Model
RELATIONSHIP
MODEL
CHAPTER 7: ENTITY-RELATIONSHIP
MODEL
• Design Process
• Modeling
• Constraints
• E-R Diagram
• Design Issues
• Weak Entity Sets
• Extended E-R Features
• Design of the Bank Database
• Reduction to Relation Schemas
• Database Design
• UML
MODELING
• A database can be modeled as:
– a collection of entities,
– relationship among entities.
• An entity is an object that exists and is distinguishable from other
objects.
– Example: specific person, company, event, plant
• Entities have attributes
– Example: people have names and addresses
• An entity set is a set of entities of the same type that share the same
properties.
– Example: set of all persons, companies, trees, holidays
ENTITY SETS INSTRUCTOR
AND STUDENT
instructor_ID instructor_name student-ID student_name
RELATIONSHIP SETS
• A relationship is an association among several entities
Example:
44553 (Peltier) advisor 22222 (Einstein)
student entity relationship set instructor entity
• A relationship set is a mathematical relation among n 2 entities, each
taken from entity sets
{(e1, e2, … en) | e1 E1, e2 E2, …, en En}
• 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 = (ID, name, street, city, salary )
course= (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
• Express the number of entities to which another entity can be
associated via a relationship set.
• Most useful in describing binary relationship sets.
• For a binary relationship set the mapping cardinality must be one of
the following types:
– One to one
– One to many
– Many to one
– Many to many
MAPPING CARDINALITIES
schema attributes
person ID, name, street, city
student ID, tot_cred
employee ID, salary
– Drawback: getting information about, an employee requires accessing two
relations, the one corresponding to the low-level schema and the one
corresponding to the high-level schema
REPRESENTING SPECIALIZATION AS
SCHEMAS
• Method 2: (CONT.)
– Form a schema for each entity set with all local and inherited attributes
schema attributes
person ID, name, street, city
student ID, name, street, city, tot_cred
employee ID, name, street, city, salary
– If specialization is total, the schema for the generalized entity set (person) not
required to store information
• Can be defined as a “view” relation containing union of specialization relations
• But explicit schema may still be needed for foreign key constraints
– Drawback: name, street and city may be stored redundantly for people who
are both students and employees
SCHEMAS CORRESPONDING TO
AGGREGATION
To represent aggregation, create a schema containing
primary key of the aggregated relationship,
the primary key of the associated entity set
any descriptive attributes
SCHEMAS CORRESPONDING TO
For example, to represent aggregation manages between
AGGREGATION (CONT.)
relationship works_on and entity set manager, create a schema
eval_for (s_ID, project_id, i_ID, evaluation_id)
Schema proj_guide is redundant provided we are willing to store null
values for attribute manager_name in relation on schema manages
E-R DESIGN DECISIONS
• The use of an attribute or entity set to represent an object.
• Whether a real-world concept is best expressed by an entity set or a
relationship set.
• The use of a ternary relationship versus a pair of binary
relationships.
• The use of a strong or weak entity set.
• The use of specialization/generalization – contributes to modularity
in the design.
• The use of aggregation – can treat the aggregate entity set as a
single unit without concern for the details of its internal structure.
HOW ABOUT DOING
ANOTHER ER DESIGN
INTERACTIVELY ON THE
BOARD?
SUMMARY OF SYMBOLS USED IN E-R
NOTATION
SYMBOLS USED IN E-R
NOTATION (CONT.)
ALTERNATIVE ER NOTATIONS
• Chen, IDE1FX, …
ALTERNATIVE ER NOTATIONS
Chen IDE1FX (Crows feet notation)
UML
• UML: Unified Modeling Language
• UML has many components to graphically model different aspects
of an entire software system
• UML Class Diagrams correspond to E-R Diagram, but several
differences.
ER VS. UML CLASS DIAGRAMS