Analyzing and validating associations ·Many-to-many -a secretary can work for many managers a manager can have many secretaries Secretaries can work in pools -Managers can have a group of secretaries -Some managers might have zero secretaries -Is it possible for a secretary to have, perhaps temporarily, zero managers Secretary Manager supervisor www.oseng.com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 11 Analyzing and validating associations • Many-to-many —A secretary can work for many managers —A manager can have many secretaries —Secretaries can work in pools —Managers can have a group of secretaries —Some managers might have zero secretaries. —Is it possible for a secretary to have, perhaps temporarily, zero managers? * supervisor 1..** Secretary Manager
Analyzing and validating associations One-to-one For each company there is exactly one board of directors a board is the board of only one company a company must always have a board a board must al ways be of some company Company BoardofDirectors www.oseng.com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 12 Analyzing and validating associations • One-to-one —For each company, there is exactly one board of directors —A board is the board of only one company —A company must always have a board —A board must always be of some company Company BoardOfDirectors
Analyzing and validating associations Avoid unnecessary one-to-one associations Avoid this do this Person PersonInfo Person nam e add ress nam e email add ress birthdate email birthdate www.oseng.com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes 13
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 13 Analyzing and validating associations Avoid unnecessary one-to-one associations Avoid this do this Person nam e address email birthdate Person nam e PersonInfo address email birthdate
A more complex example a booking is always for exactly one passenger no booking with zero passengers a booking could never involve more than one passenger A Passenger can have any number of Bookings a passenger could have no bookings at all -a passenger could have more than one booking Passenger Booking SpecificFlight www.oseng.com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes 14
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 14 A more complex example • A booking is always for exactly one passenger —no booking with zero passengers —a booking could never involve more than one passenger. • A Passenger can have any number of Bookings —a passenger could have no bookings at all —a passenger could have more than one booking * * Passenger Booking SpecificFlight
Association classes Sometimes. an attribute that concerns two associated classes cannot be placed in either of the classes The following are equivalent Student CourseSection Registratio grade Student Registration CourseSectio grade www.oseng.com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes 15
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 15 Association classes • Sometimes, an attribute that concerns two associated classes cannot be placed in either of the classes • The following are equivalent Registration grade Student CourseSection * * Registration grade Student CourseSection * *