Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database Systems ER Diagramming Tutor:Ian Perry Tel:01723 35 7287 Web:http://itsy.co.uk/units/dbs0204/http://itsy.co.uk/units/dbs0204/

Similar presentations


Presentation on theme: "Database Systems ER Diagramming Tutor:Ian Perry Tel:01723 35 7287 Web:http://itsy.co.uk/units/dbs0204/http://itsy.co.uk/units/dbs0204/"— Presentation transcript:

1 Database Systems ER Diagramming Tutor:Ian Perry Tel:01723 35 7287 E-mail:I.P.Perry@hull.ac.ukI.P.Perry@hull.ac.uk Web:http://itsy.co.uk/units/dbs0204/http://itsy.co.uk/units/dbs0204/

2 Ian PerrySlide 2 Conceptual Data Modelling 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.

3 Ian PerrySlide 3 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

4 Ian PerrySlide 4 What are the Entities? i.e. the major objects of interest. –Doctor –Nurse –Ward –Patient –Medication –Operating Theatre –Outpatients Clinic –etc.

5 Ian PerrySlide 5 What are the Attributes? i.e. the details that adequately describe each of the Entities. –Doctor Name, Room, Extension, Speciality, … –Nurse Name, Room, Extension, Speciality, … –Ward Name, Location, Number of Beds, … –Patient Name, Address, Date-of-Birth, Gender, …

6 Ian PerrySlide 6 Entity Definition Syntax: EntityName (identifier, attribute1, attribute2,...) For Example: Staff (FirstName, FamilyName, Role, Room, Extension, Speciality, …) Ward (WardName, Location, Number-of-Beds, …) Medication (DrugCode, Type, Dosage, …) Patient (FirstName, FamilyName, DOB, Address, Gender, …) Always Remember: –to indicate the ‘key’ Attribute(s).

7 Ian PerrySlide 7 ‘Type’ of Relationships? i.e. associations that are valid between Entities. –Staff work in Ward. –Patient allocated to Ward. –Patient receive Medication. –Patient is booked for Operation. –Staff perform Operation. –Patient has undergone Operation. –Patient attends Clinic. –Etc.

8 Ian PerrySlide 8 ‘Degree’ of Relationships? One_to_One (1:1) –very rare! One_to_Many (1:M or M:1) –most often used relationship, good for both Logical and Physical Modelling. Many_to_Many (M:N) –quite common, but are impossible to implement either Logically or Physically. –must be decomposed into two One-to-Many relationships linked by a ‘new’ Entity.

9 Ian PerrySlide 9 Occurrence Diagrams? Use these to get straight how many occurrences of each Entity are on either side of a Relationship. Staff Fred Smith Jane Bloggs Arthur Jones Angela Oust Ward Ward 1 Ward 2 Ward 3

10 Ian PerrySlide 10 Participation in a Relationship? Mandatory: –compulsory attachment. Contingent: –compulsion on one side only. Optional: –no compulsory attachment for either. Inclusive: –attachment only occurs when another relationship exists. Exclusive: –only one attachment from a set of possible relationships is permitted.

11 Ian PerrySlide 11 Degree, Type & Participation - 1 One-to-Many, Mandatory (compulsory) Hospital Ward has => 1M <= are in One-to-Many, Contingent (compulsion one side) PatientOperation is booked for => 1M <= performed on StaffWard work in => M N <= have Many-to-Many, Optional (no compulsion)

12 Ian PerrySlide 12 Degree, Type & Participation - 2 One-to-Many, Contingent (compulsion one side) Ward Patient has beds for => 1M <= stay in Clinic Patient caters for => 1M <= attend One-to-Many, Contingent (compulsion one side)

13 Ian PerrySlide 13 Decompose Complex Relationships WardKeyStaffKey WardKey Which MUST be decomposed into 2 x one-to-many Relationships - like this: Staff Ward Ward Team M 1 M 1 <= has work in => StaffWard work in => M N <= have Can’t have any many-to-many Relationships - for example this one:

14 Ian PerrySlide 14 Rules for Drawing ER Diagrams Need to look good, so: –don’t draw them by hand! Need to be well laid out, so that: –Entities with several Relationships are in the centre of the diagram. –Related Entities are adjacent to each other. –Relationship lines do not cross.

15 Ian PerrySlide 15 The final Degree, Type & Participation Diags. Hospital Ward has => 1M <= are in PatientOperation is booked for => 1M <= performed on Ward Patient has beds for => 1M <= stay in Clinic Patient caters for => 1M <= attend Staff Ward Ward Team M 1 M 1 <= has work in =>

16 Ian PerrySlide 16 Plan BEFORE you begin! Both ‘Patient’ and ‘Ward’ have Relationships with three other Entities: –so place these in the centre of the Diagram. ‘Ward Team’ has Relationships with two Entities: –so, place this a little further out. The other four Entities only have one Relationship each: –so, they should be placed close to the Entity that they have a Relationship with. Join all of the Entities: –indicating the Degree, Type and Participation of each Relationship.

17 Ian PerrySlide 17 Hospital Example ER Diagram has => 1 M Hospital Ward <= are in Staff Ward Team M 1 M 1 work in => has => Patient <= has beds for 1 M stay in => Clinic caters for => 1 M <= attend Operation booked for => 1 M performed on =>


Download ppt "Database Systems ER Diagramming Tutor:Ian Perry Tel:01723 35 7287 Web:http://itsy.co.uk/units/dbs0204/http://itsy.co.uk/units/dbs0204/"

Similar presentations


Ads by Google