Professional Documents
Culture Documents
ER Diagram Example
ER Diagram Example
e
A university consists of a number of departments. Each
department offers several courses. A number of modules
make up each course. Students enrol in a particular course
and take modules towards the completion of that course.
Each module is taught by a lecturer from the appropriate
department, and each lecturer tutors a group of students
ENTITYRELATIONSHIP MODELLING
Example -
Entities
A university consists of a number of departments. Each
department offers several courses. A number of modules
make up each course. Students enrol in a particular course
and take modules towards the completion of that course.
Each module is taught by a lecturer from the appropriate
department, and each lecturer tutors a group of students
ENTITYRELATIONSHIP MODELLING
Example -
Relationships
A university consists of a number of departments.
Each department offers several courses. A number of
modules make up each course. Students enrol in a
particular course and take modules towards the
completion of that course. Each module is taught by a
lecturer from the appropriate department, and each
lecturer tutors a group of students
ENTITYRELATIONSHIP MODELLING
Example - E/R
Diagram
Entities: Department, Course, Module, Lecturer, Student
Department
Student
ENTITYRELATIONSHIP MODELLING
Example - E/R
Diagram
Each department offers several courses
Offers Department
Student
ENTITYRELATIONSHIP MODELLING
Example - E/R
Diagram
A number of modules make up each courses
Offers Department
Student
ENTITYRELATIONSHIP MODELLING
Example - E/R
Diagram
Students enrol in a particular course
Offers Department
Enrols In Student
ENTITYRELATIONSHIP MODELLING
Example - E/R
Diagram
Students … take modules
Offers Department
Take
s
Enrols In Student
ENTITYRELATIONSHIP MODELLING
Example - E/R
Diagram
Each module is taught by a lecturer
Offers Department
Take
s
Enrols In Student
ENTITYRELATIONSHIP MODELLING
Example - E/R
Diagram
a lecturer from the appropriate department
Take
s
Enrols In Student
ENTITYRELATIONSHIP MODELLING
Example - E/R
Diagram
each lecturer tutors a group of students
Take
s
ENTITYRELATIONSHIP MODELLING
Example - E/R
Diagram
Offers Department Employs
Take
s
ENTITYRELATIONSHIP MODELLING
Entities and
Attributes
Sometimes it is hard to tell
if something should be an
General guidelines
◦Entities can have attributes but
entity or an attribute attributes have no smaller
◦They both represent objects parts
or facts about the world ◦Entities can have relationships
◦They are both often between them, but an
represented by nouns attribute belongs to a single
in descriptions entity
ENTITYRELATIONSHIP MODELLING
Exampl
e product has a description, a price and a supplier. Suppliers
We want to represent information about products in a database.
Each
have addresses, phone numbers, and names. Each address is made
up of a street address, a city, and a postcode.
ENTITYRELATIONSHIP MODELLING
Example -
Entities/Attributes
Entities or
attributes:
Products, suppliers, and
addresses all have smaller
◦product parts so we can make
◦description them entities
◦price
◦supplier
The others have no smaller
◦address parts and belong to a
◦phone number single entity
◦name
◦street address
◦city
◦postcode
ENTITYRELATIONSHIP MODELLING
Example - E/R
Diagram Price
Description Product
Street address
ENTITYRELATIONSHIP MODELLING
Example -
Relationships
Each product has a supplier
◦Each product has a single
Each supplier has an
address
supplier but there is nothing ◦A supplier has a single address
to stop a supplier supplying
◦It does not seem sensible for
many products
two different suppliers to
◦A many to one relationship
have the same address
◦A one to one relationship
ENTITYRELATIONSHIP MODELLING
Example - E/R
Diagram Price
Description Product
ENTITYRELATIONSHIP MODELLING
One to One
Relationships
Some relationships
between entities, A and B,
Example - the
supplier- address
might be redundant if relationship
◦It is a 1:1 relationship ◦Is one to one
between A and B ◦Every supplier has an
◦Every A is related to a B and address
every B is related to an A ◦We don’t need
addresses that
are not related to a
supplier
ENTITYRELATIONSHIP MODELLING
Redundant
Relationships
We can merge the two
entities that take part in
a x
a redundant relationship b A B y
together
◦They become a single
c z
entity
◦The new entity has all the
attributes of the old one a x
b AB y
c z
ENTITYRELATIONSHIP MODELLING
Example - E/R
Diagram Price
Description Product
Has A
ENTITYRELATIONSHIP MODELLING
Making E/R
Diagrams
From a description of the
requirements identify
Draw the E/R diagram
and then
the ◦Look at one to one
◦Entities relationships as they might be
◦Attributes redundant
◦Look at many to many
◦Relationships
relationships as they might
◦Cardinality ratios of the need to be split into two one
relationships to many links
ENTITYRELATIONSHIP MODELLING
Debugging
Designs
With a bit of practice E/R
diagrams can be used to Student
plan queries
◦You can look at the diagram How can you
and figure out how to find Has find a list of
useful information students who
◦If you can’t find the are enrolled
Enrolment in Database
information you need, you
may need to change the systems?
design
In
Module
ENTITYRELATIONSHIP MODELLING
Debugging
Designs
ID
Student
(3) For each instance of Enrolment in the
result of (2) find the corresponding Student
Name
Has
In