Lecture 3 - ERD and Enhanced ERD Modeling

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 30

Lecture 3

Entity Relationship (ER) Modeling


& Enhanced ER Modeling
Learning Objectives

• After completing this chapter, you will be able to:


• Identify the main characteristics of entity relationship components
• Describe how relationships between entities are defined, refined, and
incorporated into the database design process
• Describe the main extended entity relationship (EER) model constructs and
how they are represented in ERDs and EERDs

2
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
The Entity Relationship Model (ERM)

• Forms the basis of an entity relationship diagram (ERD)


• Conceptual database as viewed by end user
• Database’s main components
• Entities
• Attributes
• Relationships

3
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Attributes

• Characteristics of entities
• Required attribute: must have a value and cannot be left empty
• Optional attribute: does not require a value and can be left empty
• Domain: set of possible values for a given attribute

4
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Attributes (Cont.)
• Characteristics of entities
• Identifier: one or more
attributes that uniquely
identify each entity instance
• Single-valued attribute:
attribute that has only a
single value
• Multivalued attributes:
attributes that have many
values
• Derived attribute: attribute
whose value is calculated
from other attributes

5
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Relationship Strength

• Strong (identifying)
relationships
• Primary key of the related
entity contains a primary key
component of the parent
entity
• Conditions of a weak entity
• Existence-dependent
• Has a primary key that is
partially or totally derived from
parent entity in the
relationship

6
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Relationship Strength (Cont.)

7
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Relationship Strength (Cont.)

• Weak (non-identifying)
relationship
• Primary key of the
related entity does not
contain a primary key
component of the
parent entity

8
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Relationship Participation
• Optional participation
• One entity occurrence does not require a corresponding entity occurrence in a
particular relationship

• Mandatory participation
• One entity occurrence requires a corresponding entity occurrence in a
particular relationship

9
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Relationship Degree

• Indicates the number of


entities or participants
associated with a
relationship
• Unary relationship:
association is maintained
within a single entity
• Binary relationship: two
entities are associated
• Ternary relationship: three
entities are associated

10
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Recursive Relationships

• Relationship can
exist between
occurrences of the
same entity set
• Naturally, such a
condition is found
within a unary
relationship
• Common in
manufacturing
industries

11
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Developing an ER Diagram
• Tiny College (TC) is divided into
several schools: business, arts and
sciences, education, and applied
sciences.
• Each school is administered by a
dean who is a professor. Each
professor can be the dean of only
one school, and a professor is not
required to be the dean of any
school.
• Each school comprises of at least
one department e.g., the school of
business has an accounting
department, a management
department, an economics
department. Each department
belongs to only a single school.

12
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Developing an ER Diagram (Cont.)

• Each department may offer courses. For example, the management department
offers courses such as Introduction to Management and Production Management.
• Some departments that were classified as “research only,” they would not offer
courses.

13
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Developing an ER Diagram (Cont.)

• A department may offer several


sections (classes) of the same
course.
• Each class is offered during a given
semester.
• Semester defines the year and the
term that the class will be offered.

14
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Developing an ER Diagram (Cont.)

• Each department should have one or more professors assigned to it.


• One and only one of those professors chairs the department, and no professor is
required to accept the chair position.

15
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Developing an ER Diagram (Cont.)

• Each professor may teach up to four classes.


• A professor may also be on a research contract and teach no classes at all.

16
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Developing an ER Diagram (Cont.)

• A student may enroll in several classes but take each class only once during any
given enrollment period.
• Each student may enroll in up to six classes.
• Each class may have up to 35 students.

17
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Developing an ER Diagram (Cont.)

• Each department has several (or many) students whose major is offered by that
department.
• Each student has only a single major and is therefore associated with a single
department.
• In the Tiny College environment, it is possible—at least for a while—for a student
not to declare a major field of study. Such a student would not be associated with a
department yet.

18
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Developing an ER Diagram (Cont.)

• Each student has an advisor in his or her department.


• Each advisor counsels several students.
• An advisor is also a professor, but not all professors advise students.

19
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Developing an ER Diagram (Cont.)

• A class is taught in a room.


• Each room is in a building.
• In Tiny College, building can contain many rooms and each of these room is found
in a single building.
• Some buildings do not contain rooms. For example, a storage building might not
contain any named rooms at all.

20
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Developing an ER Diagram (Cont.)

21
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
The Extended Entity Relationship Model (EERM)

• Enhanced entity relationship model


• Result of adding more semantic constructs to the original entity
relationship (ER) model
• EER diagrams (EERDs) use the EER model
• Entity supertype
• Generic entity type related to one or more entity subtypes
• Contains common characteristics
• Entity subtype
• Contains unique characteristics of each entity subtype

22
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Specialization Hierarchy

• Specialization hierarchy:
• Depicts arrangement of higher-
level entity supertypes and
lower-level entity subtypes
• Relationships are described in
terms of “is-a” relationships
• Every subtype has one
supertype to which it is directly
related
• Supertype can have many
subtypes

23
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Inheritance

• Enables an entity subtype to


inherit attributes and
relationships of the supertype
• All entity subtypes inherit their
primary key attribute from their
supertype
• Entity subtypes inherit all
relationships in which supertype
entity participates
• Lower-level subtypes inherit all
attributes and relationships from
its upper-level supertypes

24
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Subtype Discriminator

• Attribute in the
supertype entity that
determines to which
entity subtype the
supertype occurrence is
related
• Default comparison
condition is the equality
comparison

25
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Disjoint and Overlapping Constraints
• Disjoint subtypes:
contain a unique subset
of the supertype entity set
• Known as nonoverlapping
subtypes
• Overlapping subtypes:
contain nonunique
subsets of the supertype
entity set
• Implementation requires
the use of one
discriminator attribute for
each subtype

26
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Disjoint and Overlapping Constraints (Cont.)

TABLE 5.1: Discriminator Attributes with Overlapping Subtypes

Discriminator Discriminator Comment


Attributes: Attributes:
Professor Administrator
Y N The Employee is a member of the Professor
subtype.
N Y The Employee is a member of the
Administrator subtype.

Y Y The Employee is both a Professor and an


Administrator.

27
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Completeness Constraint

• Specifies whether each


supertype occurrence
must also be a member of
at least one subtype
• Partial completeness: not
every supertype
occurrence is a member of
a subtype
• Total completeness:
every supertype
occurrence must be a
member of at least one
subtypes

28
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Specialization and Generalization
Specialization Generalization
Top-down process Bottom-up process
Identifies lower-level, more specific entity subtypes Identifies a higher-level, more generic entity
from a higher-level entity supertype supertype from lower-level entity subtypes
Based on grouping unique characteristics and Based on grouping common characteristics and
relationships of the subtypes relationships of the subtypes

29
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.
Summary

• The ERM uses ERDs to represent the conceptual database as viewed by


the end user
• Connectivity describes the relationship classification (1:1, 1:M, or M:N)
• ERDs may be based on many different ERMs
• Unified Modeling Language (UML) class diagrams are used to represent
the static data structures in a data model
• The extended entity relationship (EER) model adds semantics to the ER
model via entity supertypes and subtypes

30
© 2019 Cengage. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-p
rotected website for classroom use.

You might also like