Académique Documents
Professionnel Documents
Culture Documents
Steps in producing an E-R Diagram (ERD) Identify the Entities. Identify the relationships. Consider 1-to-1 relationships. Deal with M-to-N relationships. Check for dependent existence. Draw the diagram. Check for Connection Traps. Redo the Entities table if necessary.
Entities
Three rules. Each entity must have a key uniquely identifying it. The number of values for an attribute must be the same for all instances of an entity. Any relationship between entities must be 1-to-N. Identify the Entities. Summarise the information from system descriptions and the Data Flow Diagram. Identify the things described by this data. Check that the entities satisfy the first two of the Three Rules.
Member of Staff Staff ID Name Address Timetabled Class Day Time Location CourseCode StaffID
Course CourseCode Title Summary (Day, Time, Location, StaffID) (Weds, 17:15, G29, A123) (Mon, 17:15, G29, B456) (Thurs, 19:15, G38, B456)
ACE2141-3 Tony Cornah 2006/07 3
Relationships
Identify the relationships. Identify pairs of entities which have a connection. Check that the relationships satisfy the third of the Three Rules. Can one A have (more than) one B? Can one B have only one A? Consider 1-to-1 relationships. Either: Incorporate one entity into the other. Or: Keep them separate. Deal with M-to-N relationships. Create a new entity. Create two new 1-to-N relationships.
ACE2141-3 Tony Cornah 2006/07 5
Relationships are a Staff Member teaches a Class (taught by) a Class belongs to a Course (has) Can a Staff Member teach more than one Class? Can a Class be taught by only one Staff Member? Can a Class belong to (more than) one Course? Can a Course have only one Class? Can a Course have more than one Class? Can a Class belong to only one Course? Yes Yes No No Yes Yes
Member of Staff
Course
Timetabled Class
Now consider some modifications some Classes have (has) a Practical Session some Classes are taught by more than one Staff Member Can a Class have (more than) one Practical Session? Can a Practical Session be for by only one Class? Can a Staff Member teach more than one Class? Can a Class be taught by only one Staff Member? Can a Class be taught by only one Staff Member? Can a Staff Member teach more than one Class? Yes Yes Yes No No Yes
Member of Staff
Course
Check for dependent existence. Can A exist without a corresponding B? Can B exist without a corresponding A? Can a Staff Member exist without teaching? Can a Course exist without timetabled classes? Can a timetable slot exist without a Staff Member to teach and/or belonging to a Course? Yes No No
10
Draw the diagram. Entities as named boxes. Relationships as arrows from the 1 to the N. Absolute (i.e. not dependent) existence as dotted half line. Describe each end of the relationship.
11
Member of Staff
Teaches
Course
Has
Taught By
Belongs To
Timetabled Class
12
Hall of Residence
Student
If these were the relationships identified then there would be no way of discovering where a student lived. If students could live in any hall (or in private accommodation):
13
ROOM
Is Reserved By Appears In
CUSTOMER
Makes Reserves Is For Appears In Refers To Contains Made Up Of Consists Of
BOOKING
LOG ENTRY
16
17
18
Redo the Entities table if necessary. Consider these tables 1) for composite foreign keys 2) with the previous entityrelationship diagram
19
20
Creating relationships
Open the existing database and select Relationships (Right click and Show Table), Add all the tables and Close For each relationship Drag the attribute from the One side to the N side Select Enforce Referential Integrity Click Create Close, saving the changes to, Relationships
21
22
23