Lesson 7- Entity Relational Diagrams
Examples of relationships
One to One
Consider the School - Head relationship what does it tell us;
The relationship is mandatory one to one.
• one school must be managed by one head,
• one head must manage one
school.
Many to one
Consider the following ER diagram and consider what it means;
The relationship tells us that;
• one student attends one college
• one college is attended by one or more
students
Or
• every entity of the type student must attend one (and only one)
college
• every entity of the type college must be attended by one (or more)
students
What does this tell us about the application domain i.e. what are our presumptions?
• The application domain considers only students who attend college (not
those who attend school?)
• Only colleges which are attended by students (not
distance learning colleges?)
If the domain of the application is expanded to include all students listed
by Stoke Education Authority including those who attend schools. Then we
have;
• one student may attend college - Student entity has optional participation
in the 'attends' relationship.
• One college is attended by one or more
students
Note that the optionality (may/must) of a relationship is taken from the
starting entity end. Note also that the relationship
can only be defined
with a good knowledge of the application domain
Many to
Many
In a newsagent any customer can have many newspapers delivered and the same
newspaper(e.g. the Daily Mail) may be delivered to many different
customers
Many to many relationships cause difficulties in implementing in a relational database
It is therefore necessary to break these down into two one to many relationships.
To resolve the many to many relationship a third entity can be introduced
called delivery
