Sie sind auf Seite 1von 18

44220: Database Design & Implementation

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/

Conceptual Data Modelling Process


1. Identify ALL of the relevant Entities. must play a necessary role in the business system. 2. Identify those Attributes that adequately

describe each Entity.


remember to choose key attribute(s).

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:


What are the major objects of interest?




Entities

What details adequately describe each of these objects?




Attributes

What associations are valid between these objects?




Relationships
44220: Database Design & Implementation: ER Diagramming Slide 3

Ian Perry

What are the Entities?




i.e. the major objects of interest.


       

Doctor Nurse Ward Patient Medication Operation Clinic etc.


44220: Database Design & Implementation: ER Diagramming Slide 4

Ian Perry

What are the Attributes?




i.e. the details that adequately describe each of the Entities.




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:


EntityName (key attribute(s), attribute, ...)

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:


to indicate the key Attribute(s).


44220: Database Design & Implementation: ER Diagramming Slide 6

Ian Perry

Type of Relationships?


i.e. associations which are valid, in BOTH directions, between pairs of Entities.


Patient has Operation.




Operation performed on Patient Ward employs Staff Patient stays in Ward Clinic treats Patient
44220: Database Design & Implementation: ER Diagramming Slide 7

Staff work in Ward




Ward has beds for Patient




Patient attends Clinic





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)


MUST be decomposed into two One-to-Many relationships linked by an artificial Entity.


44220: Database Design & Implementation: ER Diagramming Slide 8

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

44220: Database Design & Implementation: ER Diagramming

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

Degree, Type & Participation - 1


One-to-Many, Contingent (compulsion one side)
Ward
1

has beds for => M <= stays in

Patient

One-to-Many, Contingent (compulsion one side)


Clinic
1

treats => <= attends

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

Degree, Type & Participation - 2


Many-to-Many, Contingent (compulsion one side)
Patient
M

has => <= performed on

Operation

Many-to-Many, Contingent (compulsion one side)


Staff
M

work in => <= employs

Ward

Ian Perry

44220: Database Design & Implementation: ER Diagramming

Slide 12

Decompose Complex Relationships


Cant have any Many-to-Many Relationships; for example this one:
Staff
M

work in => <= employs

Ward

MUST be decomposed into 2 x One-to-Many Relationships, linked by an artificial Entity, i.e.:


Staff
FirstName FamilyName

work in =>

Team
FirstName FamilyName WardName

<= employs

Ward
WardName

Ian Perry

44220: Database Design & Implementation: ER Diagramming

Slide 13

Rules for Drawing ER Diagrams




Need to look good:




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.

Need to be well laid out, so that:




Ian Perry

44220: Database Design & Implementation: ER Diagramming

Slide 14

The final Degree, Type & Participation Diags. Ward Clinic


1

has beds for => M <= stays in

Patient Patient

treats => <= attends

NB. the above Relationships are also Exclusive.


Staff
1 has => 1 M

work in =>

Team

<= employs

Ward

Patient

Pat/Op

<= performed on

Operation

i.e. having now solved BOTH M:M Relationship problems .


Ian Perry 44220: Database Design & Implementation: ER Diagramming Slide 15

Plan BEFORE you begin!




Patient has Relationships with THREE other Entities:




so, place Patient in centre of the Diagram.

Ward, Team & Pat/Op have Relationships with TWO other Entities:


so, place these a little further out.

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

Join all of the Entities:




Ian Perry

ER Diagram for a Hospital


Clinic
1 <= attends treats => M 1 <= stays in M has => 1 M has beds for =>

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

This Weeks Workshop




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.


The same is true for Assignment 1.

Part 1 - Draw Degree, Type & Participation diagrams, which:




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

Part 2 - Begin working on Assignment 1, by:


 

Ian Perry

Das könnte Ihnen auch gefallen