180 likes | 265 Views
Feb 18, 2002 Review of some modeling concepts Introduction of Moment-Interval. Association Classes (Pages 411-414). In a typical university: We have an Course class and a Student class. A Student enrolls in an Course and is eventually assigned a grade.
E N D
Feb 18, 2002Review of some modeling conceptsIntroduction of Moment-Interval 91.3913 R McFadyen
Association Classes (Pages 411-414) • In a typical university: • We have an Course class and a Student class. • A Student enrolls in an Course and is eventually assigned a grade. • A Student may enroll in several Courses. • A Course will have many Students enrolled. • Consider : * * Student Course • Where is the student’s grade kept? • We can’t keep it with Student … nor with Course 91.3913 R McFadyen
Association Classes * * Student Course courseNum Enrollment grade • Grade is considered an attribute that belongs to the association between a student and a course. • If your model has a many-to-many association between two classes, then there will likely be a need for an association class 91.3913 R McFadyen
Association Classes * * Student Course courseNum studNum Suppose we have 3 students taking one or two courses : Enrollment grade 123 2914 333 789 3913 91.3913 R McFadyen
Association Classes * * Student Course courseNum studNum Enrollment grade • Now suppose • we need to track these grades over several terms • we need to know what grades a student received for a course that was repeated more than once. • The above model doesn’t accommodate this - there are different approaches 91.3913 R McFadyen
Association Classes * * * Student Offering Course courseNum studNum term instructor Enrollment grade Associate a collection of Offerings with a course - each offering is associated with a particular time interval (in this case the time interval is duration of the term) Section 27.3 refers to a Moment-Interval archetype - a concept promoted by Peter Coad. The idea recognizes that some things that we need to track, either occur at a moment in time, or, they occur over an interval of time. 91.3913 R McFadyen
Moment-Interval archetype <<moment-interval>> Offering term instructor Coad would indicate these types of classes with the designation: <<moment-interval>>, and, they would be coloured: Colour makes these kinds of classes stand out in a diagram. <<moment-interval>> Offering term instructor Supposed to be pink 91.3913 R McFadyen
Association Class Wouldn’t this work too? (and there’s no association class) 1 * * 1 Offering Student Enrollment term instructor studNum grade • What’s different? • This permits the same course and the same student to be related several times • Enrollment is promoted to a full-fledged class • There are two associations now, instead of one 91.3913 R McFadyen
Peter Coad & Moment-Interval <<moment-interval>> Offering <<Thing>>Course * term courseNum instructor courseNum * <<Thing>> Student * <<moment-interval>> Enrollment studNum grade 91.3913 R McFadyen
Peter Coad & Four Archetypes <<Role>> PartyRole • A role is a way of participation by a person, place, or thing. • Instead of Person, Coad uses Party since it captures both person and organization. • A Cashier accepts the payment • An Instructor gives a mark • A clerk processes the registration <<Role>> ThingRole <<Role>> PlaceRole 91.3913 R McFadyen
Peter Coad & Four Archetypes <<Description>> PartyDescription • A Description is a catalogue-entry-like description. It is a collection of values that apply again and again. <<Description>> ThingDescription <<Description>> PlaceDescription 91.3913 R McFadyen
Peter Coad & Four Archetypes A Party, Place, or Thing is someone or something that plays different roles. A person might be both an employee and a customer. A Place might be both a retail outlet and a wholesale outlet. A Thing might play one role in a manufacturing process and a different role in a purchasing process <<Party>> Party <<Thing>> Thing <<Place>> Place 91.3913 R McFadyen
Peter Coad & Four Archetypes • Something one works with and tracks for business or legal reasons, • Something that occurs at a moment in time, or over an interval of time • A sale is made at a moment in time • A rental happens over an interval of time • A reservation occurs over an interval of time <<moment-interval>> MomentInterval 91.3913 R McFadyen
Peter Coad & Four Archetypes <<Description>> PartyDescription <<Description>> PlaceDescription <<moment-interval>> MomentInterval <<Party>> Party <<Place>> Place number date total ... <<Role>> PartyRole <<Role>> PlaceRole makeMomentInterval addDetail calcTotal ... Coad calls this pattern the Domain Neutral Component <<Role>> ThingRole <<Thing>> Thing <<Description>> ThingDescription 91.3913 R McFadyen
Peter Coad & Four Archetypes <<Role>> Customer <<Role>> BusinessLocation * * <<moment-interval>> CashSale * <<Role>> Cashier * <<moment-interval>> Payment * <<moment-interval>> CashSaleDetail Not all components must be there * <<Description>> ProductDescription 91.3913 R McFadyen
From the text A SalesLineItem is related to a ProductSpecification which is associated with a collection of ProductPrice Which class is the Moment-Interval? 91.3913 R McFadyen
Reflexive Associations (section 27.8) parent child parent Would an association class be of any use here? 91.3913 R McFadyen
Reflexive Associations * * wife husband marries Would an association class be of any use here? 91.3913 R McFadyen