Database DesignSlide 2Slide 3RelationshipsDependencies (1)Dependencies (2)Associations (1)Types of AssociationAssociations (2)Associations (3)Associations (4)More on AssociationsSlide 13Slide 14Slide 15Slide 16More MultiplicitiesSlide 18N-ary AssociationMore on n-ary AssociationSlide 21Slide 22Slide 24Association ClassAggregation & CompositeSlide 27Slide 28AggregationSlide 30Aggregation ProblemSlide 32AttributesMore on AttributesSlide 35Generalization (1)Generalization (2)InheritanceBase and Leaf ClassesMore on InheritanceSingle and Multiple InheritanceAggregation vs. InheritanceDiscussion Questions© 2003-2006 Dr. M.E. FayadSJSU -- CmpEDatabase DesignDr. M.E. Fayad, ProfessorComputer Engineering Department, Room #283I College of EngineeringSan José State UniversityOne Washington SquareSan José, CA 95192-0180 http://www.engr.sjsu.edu/~fayad© 2003-2006 Dr. M.E. FayadSJSU -- CmpE M.E. Fayad L4-S2 Relationships2Lesson 04A:Relationships© 2003-2006 Dr. M.E. FayadSJSU -- CmpE M.E. Fayad L4-S3 Relationships Lesson ObjectivesObjectives3Discuss UML AssociationsDiscuss UML – aggregationUnderstand UML- inheritanceUnderstand How to identify UML Artifacts© 2003-2006 Dr. M.E. FayadSJSU -- CmpE M.E. Fayad L4-S4 RelationshipsA relationship is a connection among thingsThree most important relationships in OO–dependencies–generalizations–associationsDifferent kind of lines are used to distinguish various kinds of relationships4Relationships© 2003-2006 Dr. M.E. FayadSJSU -- CmpE M.E. Fayad L4-S5 RelationshipsDependencies are using relationshipsState that a change in specification of one thing (the supplier) may affect another thing that uses it (the client), but not necessary the reverseGraphically, it is rendered as a dashed directed line5Dependencies (1)© 2003-2006 Dr. M.E. FayadSJSU -- CmpE M.E. Fayad L4-S6 Relationships6Dependencies (2)Dependent ClassIndependent ClassOrderBookClientSupplier© 2003-2006 Dr. M.E. FayadSJSU -- CmpE M.E. Fayad L4-S7 RelationshipsAn association shows a two-way relationship between objects (instances) of two or more classes and requiring special implementation to ensure integrity.A particular instance of an association is often called a link.Associations between classes are required if the objects need to communicate.Associations are often named, and have role-names for each side of the link.7Associations (1)© 2003-2006 Dr. M.E. FayadSJSU -- CmpE M.E. Fayad L4-S8 RelationshipsUnary association–both ends of an association circle back to the same classBinary association–an association that connects exactly two classesN-ary association–an association that connects more than two classes8Types of Association© 2003-2006 Dr. M.E. FayadSJSU -- CmpE M.E. Fayad L4-S9 RelationshipsName–an association can have a name, and the name is used to describe the nature of the relationshipRole–when a class participates in an association, it has a specific role that it plays in that relationship–a role is just the face the class at the near end of the association presents to the class at the other end of the association9Associations (2)© 2003-2006 Dr. M.E. FayadSJSU -- CmpE M.E. Fayad L4-S10 Relationships10Associations (3)Association NamePersonnameageaddressCarmodelyear# of doorsregisteredCar ownerVehicle RegistrationRoles Names© 2003-2006 Dr. M.E. FayadSJSU -- CmpE M.E. Fayad L4-S11 Relationships11Associations (4)Person Company1..**Owns byNameemployeeemployerRole NameMultiplicity© 2003-2006 Dr. M.E. FayadSJSU -- CmpE M.E. Fayad L4-S12 RelationshipsSimple example:An association has a name and a numerical specification (multiplicity indication) of how many objects on one side of the association are connected with how many objects on the other side.Associations are called use relationships – even if this may seem somewhat cheeky in the example below12More on AssociationsWindow GeomFiguredisplays 0..*Company Personemploys 0..*Employer Employee© 2003-2006 Dr. M.E. FayadSJSU -- CmpE M.E. Fayad L4-S13 RelationshipsAssociations are directed (one way), bidirectional, and undirected.UML makes no distinction between bidirectional and undirected associations.13More on AssociationsClass1 Class2StereotypeRelationName{Constraints}*role1 Role2: interfaceMultiplicity© 2003-2006 Dr. M.E. FayadSJSU -- CmpE M.E. Fayad L4-S14 RelationshipsRecursive association: A class has a relation with itself.It is also possible to model associations that are valid only temporarily “stereotype or temporary”Constraints may be used to restrict the relation under specific aspects.A role name describes how the object is seen by the opposite object in the association.An association can be described in more detail by means of constraints, tagged values, and stereotypes.Stereotypes are noted before or above the relation name, constraints, and tagged values after or below the name.14More on Associations© 2003-2006 Dr. M.E. FayadSJSU -- CmpE M.E. Fayad L4-S15 RelationshipsDirected association is a one-way association, in which one side knows the other, but not vice versa.Multiplicity Specification:–1 exactly one–0, 1 zero or one–0..4 between zero and four–3, 7 either three or seven15More on Associations© 2003-2006 Dr. M.E. FayadSJSU -- CmpE M.E. Fayad L4-S16 RelationshipsMore multiplicity specifications:–0..* greater than or equal to zero (default)–* ditto–1..* greater than or equal to one–0..3, 7, 9..* between zero and three, or exactly seven, or greater than or equal to nine.16More on Associations© 2003-2006 Dr. M.E. FayadSJSU -- CmpE M.E. Fayad L4-S17 RelationshipsMultiplicity–how many objects may be connected across an instance of an association–can be a range of values or an explicit value•exactly one 1•zero or one (optional) 0..1•zero or more (many) 0..*•one or more (mandatory) 1..*•numerically specified m..n17More Multiplicities© 2003-2006 Dr. M.E. FayadSJSU -- CmpE M.E. Fayad L4-S18 RelationshipsRecursive associations are associations in which one class is involved.18More on AssociationsEmployeenamestaffNoroomNoPersonPatient1managerreports toleadsoffice clerkhas**relative© 2003-2006 Dr. M.E. FayadSJSU -- CmpE M.E. Fayad L4-S19 RelationshipsAn n-ary association is like a common (binary) association, except that more than two association roles involved in it. 19N-ary AssociationClass1
View Full Document