Module 1 : Entity-Relationship (ER) diagrams

Conceptual Database Design

The Entity - Relationship Model

It helps:

Entities

An entity is essentially a physical or conceptual object which has data associated with it.

NOTE: all the diagrams shown are snippets for the Entity Relation Diagram Exmple here


Entity

An entity type provides a format for the data which needs to be recorded to represent a particular entity. The entity type is described by its name and attributes. Represented as a rectangular box

LECTURER
LECTURER
Text is not SVG - cannot display


Key Attributes

All entity types have at least one key (or uniqueness) constraint. The key must hold for every possible extension of the entity type (see super/subclasses in later slides). Represented as an underlined attribute.

NOTE: StaffID is underlined!

StaffID
StaffID
Text is not SVG - cannot display


Simple Attributes

Attributes used to describe an entity

D.O.B
D.O.B
Text is not SVG - cannot display


Composite attributes

Composite attributes can be divided into smaller parts which represent simple attributes with independent meaning

Name
Name
FirstName
FirstName
MiddleInitial
MiddleInitial
lastName
lastName
Text is not SVG - cannot display


Composite Key attribute (Several Attribute Keys)

A composite key attribute is also a unique identifiers for each entity instance.
It is the combination of simple attributes which make up the composite key which must be unique

NOTE: Name is underlined!

Key
Key
CourseCode
CourseCode
Semester
Semester
Year
Year
Text is not SVG - cannot display


Multivalued attributes

Multivalued attributes are shown with double-lined ovals and can have multiple values (e.g., one person can hold multiple degrees)

Publications
Publications
Text is not SVG - cannot display


Derived Attributes

|In some cases, attribute values can be derived from related attribute values (e.g., age can be derived from BirthDate)

STUDENT
STUDENT
Age
Age
D.O.B
D.O.B
Text is not SVG - cannot display


Entity Concepts

Value sets of attributes

Value sets specify the set of values that may be assigned to a particular attribute of an entity

it is essentially the 'Domain' of the attribute, but often it is not simply an integer domain. We will focus on this later.

Entity Set

The collection of all entities of a particular entity type in the database at any point in time is referred to as an entity set.

Alt text

Relationships

A relationship is an association among two or more entities

A relationship type defines the relationship.

Relationship Concepts


Relationship

In the ER model, relationships are represented using a diamond that is connected to the associated entity types. A relationship type may have descriptive attributes. A relationship type may have key attributes

LECTURES
LECTURES
Text is not SVG - cannot display


Relationship Degree

The degree of a relationship type is the number of participating entity types. 2 Entities: Binary relationship. 3 entities: Ternary relationship. n entities: n-ary relationship (3 + entities)

BINARY

LECTURES
LECTURES
COURSE
COURSE
LECTURER
LECTURER
1
1
N
N
Text is not SVG - cannot display

TERNARY

STUDENT
STUDENT
PARTICIPATES
PARTICIPATES
ENROLMENT
ENROLMENT
COURSE
COURSE
N
N
M
M
1
1
Text is not SVG - cannot display


Role Name

The role name signifies the role that a participating entity from the entity type plays in each relationship instance. That is to say, it explains what the relationship means.

E.g. LECTURES and PARTICPATES from the Relationship above


Recursive Relationships

Same entity types can participate more than once in the same relationship type under different “roles”.

LECTURER
LECTURER
SUPERVISES
SUPERVISES
Supervisor
Supervisor
Supervisee
Supervisee
Text is not SVG - cannot display


Relationship Constraints

Cardinality Constraints

A cardinality ratio for a relationship set specifies the number of relationships in the set that an entity can participate in.

Alt text


Participation constraints

Existence Dependency

Existence dependency indicates whether the existence of an entity depends on its relationship to another entity.

Example: Every Course must be lectured by a lecturer.

LECTURES
LECTURES
COURSE
COURSE
LECTURER
LECTURER
1
1
N
N
Text is not SVG - cannot display


Weak Entities

STUDENT
STUDENT
PARTICIPATES
PARTICIPATES
ENROLMENT
ENROLMENT
COURSE
COURSE
N
N
M
M
1
1
Text is not SVG - cannot display


Superclasses and Subclasses - Enhanced ER Model

In the enhanced ER model, the entity type is called a class

Key points to note:

Example

The superclass captures the data common for a variety of different objects. The STUDENT class captures data such as the name, StudentID and DOB which is important for all kinds of students (see example here).

the subclass entities POSTGRADUATE AND UNDERGRADUATE, which are extensions of the STUDENT class, define properties (attributes) specific to those subclasses.

STUDENT
STUDENT
POSTGRADUATE
POSTGRADUATE
UNDERGRADUATE
UNDERGRADUATE
d
d
Text is not SVG - cannot display

Specialisation

Generalisation