Beruflich Dokumente
Kultur Dokumente
ER Diagramming
Ian Perry
Room: C41C Tel Ext.: 7287 E-mail: I.P.Perry@hull.ac.uk
http://itsy.co.uk/ac/0809/sem2/44220_DDI/
3. Identify the Relationships between Entities. determine the Degree of each Relationship: determine the Type of each Relationship. attempt to decompose any many-to-many Relationships that you have identified.
Ian Perry 44220: Database Design & Implementation: ER Diagramming Slide 2
Hospital Example
Let us suppose that you have been asked to
build a Conceptual Data Model for a Hospital. The questions you must ask (and answer?) are as follows:
Entities
Attributes
Relationships
44220: Database Design & Implementation: ER Diagramming Slide 3
Ian Perry
Ian Perry
Ward
Name, Location, Number of Beds, Name, Address, Date-of-Birth, Gender, Name, Room, Extension, Speciality, Name, Room, Extension, Speciality, Perhaps people who work in the Hospital could be described using ONE Entity, i.e. Staff?
44220: Database Design & Implementation: ER Diagramming Slide 5
Patient
Doctor
Nurse
NB.
Ian Perry
Entity Definition
Syntax:
For Example:
Staff (FirstName, FamilyName, Role, Room, Extension, Speciality, ) Ward (WardName, Location, Number-of-Beds, ) Medication (DrugCode, Type, Dosage, ) Patient (FirstName, FamilyName, DOB, Gender, Street, Town, Post Code, Tel. No., )
Always Remember:
Ian Perry
Type of Relationships?
i.e. associations which are valid, in BOTH directions, between pairs of Entities.
Operation performed on Patient Ward employs Staff Patient stays in Ward Clinic treats Patient
44220: Database Design & Implementation: ER Diagramming Slide 7
Ian Perry
Etc.
Degree of Relationships?
One-to-One (1:1)
Very rare!
Quite rare as a real world relationship; however, what we require for both Logical and Physical Modelling. Most common as a real world relationship; however, impossible to implement Logically or Physically.
One-to-Many (1:M)
Many-to-Many (M:M)
Ian Perry
Occurrence Diagrams?
Use these (with values for Key Attributes) to discover how many occurrences of each Entity are actually on either side of a Relationship.
Staff
Fred Smith Jane Bloggs Arthur Jones Angela Oust
M 1
Ian Perry
Ward
Ward 1 Ward 2 Ward 3
M 1
Slide 9
Participation in a Relationship?
Mandatory:
compulsory attachment on both sides (very rare). compulsion on one side only (most common). no compulsory attachment for either Entity (rare). attachment only occurs when another relationship exists (very rare). only one attachment from a set of possible relationships is permitted (quite rare).
44220: Database Design & Implementation: ER Diagramming Slide 10
Contingent:
Optional:
Inclusive:
Exclusive:
Ian Perry
Patient
Patient
NB. a Patient can NOT both be staying in a Ward AND attending the Clinic, so these two Relationships are also Exclusive.
Ian Perry 44220: Database Design & Implementation: ER Diagramming Slide 11
Operation
Ward
Ian Perry
Slide 12
Ward
work in =>
Team
FirstName FamilyName WardName
<= employs
Ward
WardName
Ian Perry
Slide 13
So, DONT draw them by hand! Entities with several Relationships are in the centre of the diagram. AND related Entities are adjacent to each other. AND Relationship lines do not cross.
Ian Perry
Slide 14
Patient Patient
work in =>
Team
<= employs
Ward
Patient
Pat/Op
<= performed on
Operation
Ward, Team & Pat/Op have Relationships with TWO other Entities:
The other 3 Entities (i.e. Staff, Operation & Clinic only have ONE Relationship:
so, they should be placed on the outside of the digaram, close to the Entity that they have a Relationship with. indicating the Degree, Type and Participation of each Relationship.
44220: Database Design & Implementation: ER Diagramming Slide 16
Ian Perry
Ward
has => 1 M
Team
M <= work in
#==========#
Staff Pat/Op
<= performed on M
Patient
Operation
Ian Perry 44220: Database Design & Implementation: ER Diagramming Slide 17
The purpose of this weeks Workshop it to check that you can create good looking ER Diagrams, using a suitable software tool.
If you havent already got a favourite drawing application I suggest you use PowerPoint.
Your ER Diagrams MUST follow the diagram conventions given in this lecture.
depict 4, relatively simple, real-world situations. identifying the Entities from the Case Study. then, drawing Occurrence diagrams for each Pair of Entities.
44220: Database Design & Implementation: ER Diagramming Slide 18
Ian Perry