04-Entity-Relational Model (Part 1) - SCD
04-Entity-Relational Model (Part 1) - SCD
Learning Outcomes
Students can explain and understand ER, ER Notation (CLO1)
and make a simple ERD using the right ER Notation, according to
the case study (CLO2)
Outline
3
Basic Concepts
Complex Attributes
Mapping Cardinalities
Primary Keys
Weak Entity Sets
Entity Relationship Design Issues
Extended ER Features (additional)
Alternative Notation for Modelling Data (additional)
4
Basic Concepts
ER Model
5
student
Degree of a Relationship Sets
10
• 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. There are occasions when it is more convenient to represent relationships as
non-binary.
• Example: students work on research projects under the guidance of an instructor.
• relationship proj_guide is a ternary relationship between instructor, student, and
project
Roles
11
Complex Attributes
Complex Attributes
13
• Attribute types:
• Simple and composite attributes.
• Composite attributes allow us to divided
attributes into subparts (other
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
• Domain – the set of permitted values for each
attribute
14
Mapping Cardinalities
Mapping Cardinality Constraints
15
• 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:
▪ Total participation (indicated by double line): every entity in the entity set participates
in at least one relationship in the relationship set
• Instructor can advise 0 or more students. A student must have 1 advisor; cannot
have multiple advisors
19
Primary Keys
Primary Key
20
• The values of the attribute values of an entity must be such that they can uniquely
identify the entity.
• No two entities in an entity set are allowed to have exactly the same value for all
attributes.
• A key for an entity is a set of attributes that suffice to distinguish entities from each
other
Primary Key for Relationship Sets
22
• The choice of the primary key for a relationship set depends on the mapping
cardinality of the relationship set.
Choice of Primary key for Binary Relationship
23
• Many-to-Many relationships.
The preceding union of the primary keys is a minimal superkey and is chosen as the
primary key.
• One-to-Many relationships .
The primary key of the “Many” side is a minimal superkey and is used as the primary
key.
• Many-to-one relationships.
The primary key of the “Many” side is a minimal superkey and is used as the primary
key.
• One-to-one relationships.
The primary key of either one of the participating entity sets forms a minimal
superkey, and either one can be chosen as the primary key.
24
• An entity that does not have a specific identifier. A weak entity must participate in an
identifying relationship type with an owner or identifying entity type.
• The primary key of a weak entity set is formed by the primary key of the strong entity
set on which the weak entity set is existence dependent, plus the weak entity set’s
discriminator.
• The discriminator (or partial key) of a weak entity type is the set of attributes that
distinguishes among all the entities of a weak entity type.
• An entity set that is not a weak entity set is termed a strong entity set.
• Every weak entity must be associated with an identifying entity; that is, the weak entity
set is said to be existence dependent on the identifying entity set.
• The identifying entity set is said to own the weak entity set that it identifies.
• The relationship associating the weak entity set with the identifying entity set is called
the identifying relationship.
Expressing Weak Entity Sets
26
Entity Relationship
Design Issues
Common Mistakes in E-R Diagrams
28
1. The use of the primary key of an entity set as an attribute of another entity
set, instead of using a relationship.
Extended ER Features
(additional)
Extended ER Features
33
• Although the basic E-R concepts can model most database features, some
aspects of a database may be more aptly expressed by certain extensions to
the basic E-R model.
• In this section, we discuss the extended E-R features of :
• specialization,
• generalization,
• higher- and lower-level entity sets,
• attribute inheritance, and
• aggregation.
Specialization
34
▪ 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.)
39
References