ER Model

COMP3311 20T3 ♢ ER Model ♢ [0/19]
❖ Entity-Relationship Data Modelling


The world is viewed as a collection of inter-related entities.

ER has three major modelling constructs:

The ER model is not a standard, so notational variations exist

Lecture notes use notation from SKS and GUW books (simple)

COMP3311 20T3 ♢ ER Model ♢ [1/19]
❖ Entity-Relationship (ER) Diagrams

ER diagrams are a graphical tool for data modelling.

An ER diagram consists of:


Terminology abuse:
COMP3311 20T3 ♢ ER Model ♢ [2/19]
❖ Entity-Relationship (ER) Diagrams (cont)

Example ER diagram:


[Diagram:Pics/er-rel/er1.png]

COMP3311 20T3 ♢ ER Model ♢ [3/19]
❖ Entity-Relationship (ER) Diagrams (cont)

Example of attribute notations:

[Diagram:Pics/er-rel/erattrs.png]

COMP3311 20T3 ♢ ER Model ♢ [4/19]
❖ Entity Sets

An entity set can be viewed as either:

Key (superkey): any set of attributes Candidate key = minimal superkey (no subset is a key)

Primary key = candidate key chosen by DB designer

Keys are indicated in ER diagrams by underlining

COMP3311 20T3 ♢ ER Model ♢ [5/19]
❖ Keys

Sometimes primary keys are obvious ...

[Diagram:Pics/er-rel/keys.png]

COMP3311 20T3 ♢ ER Model ♢ [6/19]
❖ Example: Identifying Keys

Candidate keys in the following ER diagram ...

[Diagram:Pics/er-rel/keys2.png]


Possibilities:   {studentID},   {phone},   {email},   {name,address,d-o-b}?

COMP3311 20T3 ♢ ER Model ♢ [7/19]
❖ Relationship Sets

Relationship: an association among several entities

Relationship set: collection of relationships of the same type

Degree = # entities involved in reln (in ER model, ≥ 2)

Cardinality = # associated entities on each side of reln

Participation = must every entity be in the relationship

Example: relationship participation

[Diagram:Pics/er-rel/participation.png]

COMP3311 20T3 ♢ ER Model ♢ [8/19]
❖ Relationship Sets (cont)

Examples: relationship degree


[Diagram:Pics/er-rel/reln-degree.png]

COMP3311 20T3 ♢ ER Model ♢ [9/19]
❖ Relationship Sets (cont)

Examples: relationship cardinality


[Diagram:Pics/er-rel/cardinal.png]

COMP3311 20T3 ♢ ER Model ♢ [10/19]
❖ Example: Relationship Semantics

Semantics of the following relationships ...

[Diagram:Pics/er-rel/example-rel.png]

COMP3311 20T3 ♢ ER Model ♢ [11/19]
❖ Example: Relationship Semantics (cont)

In some cases, a relationship needs associated attributes.


[Diagram:Pics/er-rel/relattr.png]


(Price and quantity are related to products in a particular shop)

COMP3311 20T3 ♢ ER Model ♢ [12/19]
❖ Weak Entity Sets

Weak entities

Example:

[Diagram:Pics/er-rel/weakent.png]

COMP3311 20T3 ♢ ER Model ♢ [13/19]
❖ Subclasses and Inheritance

A subclass of an entity set A is a set of entities:

Properties of subclasses: Special case: entity has one subclass ("B is-a A" specialisation)


[Diagram:Pics/er-rel/is-a.png]

COMP3311 20T3 ♢ ER Model ♢ [14/19]
❖ Subclasses and Inheritance (cont)

Example:

[Diagram:Pics/er-rel/inherit.png]

COMP3311 20T3 ♢ ER Model ♢ [15/19]
❖ Design Using the ER Model


ER model: simple, powerful set of data modelling tools

Some considerations in designing ER models:

Answers to above are worked out by thinking about the application domain.
COMP3311 20T3 ♢ ER Model ♢ [16/19]
❖ Large ER Diagrams


ER diagrams are typically too large to fit on a single screen
(or a single sheet of paper, if printing)

One commonly used strategy:

COMP3311 20T3 ♢ ER Model ♢ [17/19]
❖ Large ER Diagrams (cont)

Example of drawing large ER diagram:

[Diagram:Pics/er-rel/large-ER.png]

COMP3311 20T3 ♢ ER Model ♢ [18/19]
❖ Summary of ER


ER model is popular for doing conceptual design

Basic constructs:   entities,   relationships,   attributes

Relationship constraints:   total / partial,   n:m / 1:n / 1:1

Other constructs:   inheritance hierarchies,   weak entities

Many notational variants of ER exist
(especially in the expression of constraints on relationships)

COMP3311 20T3 ♢ ER Model ♢ [19/19]


Produced: 13 Sep 2020