L4-S1Relationships 2003 SJSU -- CmpE Database Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San José.

Slides:



Advertisements
Similar presentations
Text-Book Chapters (7 and 8) Entity-Relationship Model
Advertisements

UML Class Diagram. UML Class Diagrams2 Agenda What is a Class Diagram? Essential Elements of a UML Class Diagram Tips.
Fall 2002 SJSU -- CmpE Enterprise & Application Frameworks Dr. M.E. Fayad, Professor Computer Engineering Department – RM# College of Engineering San José.
2008/03/25 Unified Modeling Lanauage 1 Introduction to Unified Modeling Language (UML) – Part One Ku-Yaw Chang Assistant Professor.
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
L3-1-S1 OO Concepts © M.E. Fayad SJSU -- CMPE Software System Engineering Dr. M.E. Fayad, Professor Computer Engineering Department, Room.
L3-5c-S1 Object Diagrams © M.E. Fayad SJSU -- CmpE Software System Engineering Dr. M.E. Fayad, Professor Computer Engineering Department,
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
L16-S1 Object Diagrams 2003 SJSU -- CmpE Software Patterns Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering.
L28-S1 Interaction Diagrams 2003 SJSU -- CmpE Advanced Object-Oriented Analysis & Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room.
L19-S1 More on Class Diagrams 2003 SJSU -- CmpE Object-Oriented Analysis & Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I.
Chapter 14 (Web): Object-Oriented Data Modeling
L3-5d-S1 Class Diagrams © M.E. Fayad SJSU -- CmpE Software System Engineering Dr. M.E. Fayad, Professor Computer Engineering Department, Room.
May-June 2001 ISISTAN Research Institute – Tandil, Argentina Software Design Methodologies: UML in Action Dr. Mohamed Fayad, J.D. Edwards Professor Department.
L8-S1 CRC Cards 2003 SJSU -- CmpE Advanced Object-Oriented Analysis & Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 Class and Object Diagrams PRACTICAL OBJECT-ORIENTED DESIGN WITH.
7M822 UML Class Diagrams advanced concepts 15 September 2008.
Chapter 2: Entity-Relationship Model (Continued)
© M.E. Fayad SJSU -- CmpE Software System Engineering Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering.
Chapter 4 Entity-Relationship modeling Transparencies © Pearson Education Limited 1995, 2005.
Chapter 14: Object-Oriented Data Modeling
UML Class Diagrams: Basic Concepts. Objects –The purpose of class modeling is to describe objects. –An object is a concept, abstraction or thing that.
DeSiamorewww.desiamore.com/ifm1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
Lawrence ChungCS6359.0T1: Module 41 Module 4: Relationships.
Module Title? Data Base Design 30/6/2007 Entity Relationship Diagrams (ERDs)
Chapter 5 Entity–Relationship Modeling
Conceptual Data Modeling. What Is a Conceptual Data Model? A detailed model that shows the overall structure of organizational data A detailed model.
Database Management System Prepared by Dr. Ahmed El-Ragal Reviewed & Presented By Mr. Mahmoud Rafeek Alfarra College Of Science & Technology Khan younis.
R McFadyen Chapter 7 Conceptual Data Modeling.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
CHAPTER 13 (ONLINE): OBJECT-ORIENTED DATA MODELING © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition.
1 © Prentice Hall, 2002 Chapter 14: Object-Oriented Data Modeling Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R.
© 2011 Pearson Education 1 Chapter 13 (Online): Object-Oriented Databases Modern Database Management 10 th Edition, International Edition Jeffrey A. Hoffer,
7-1 © Prentice Hall, 2007 Chapter 7: Conceptual Data Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 15: Object-Oriented Data Modeling Modern Database Management 9 h Edition Jeffrey A.
Unit 3 Conceptual Data Modeling. Key Concepts Conceptual data modeling process Classes and objects Attributes Identifiers, candidate keys, and primary.
7-1 © Prentice Hall, 2007 Week 5: Conceptual Data Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
Databases : Data Modeling 2007, Fall Pusan National University Ki-Joune Li.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 13 (Online): Object-Oriented Data Modeling Modern Database Management 10 th Edition.
Chapter 12 Entity-Relationship Modeling Pearson Education © 2009.
CHAPTER 13: OBJECT-ORIENTED DATA MODELING (OVERVIEW) © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition.
UML Class Diagram Trisha Cummings. What we will be covering What is a Class Diagram? Essential Elements of a UML Class Diagram UML Packages Logical Distribution.
Initial Design of Entity Types for the COMPANY Database Schema Based on the requirements, we can identify four initial entity types in the COMPANY database:
DeSiamorePowered by DeSiaMore1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
Msigwaemhttp//:msigwaem.ueuo.com/1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
Lecture 1: UML Class Diagram September 12, UML Class Diagrams2 What is a Class Diagram? A class diagram describes the types of objects in the system.
Class Diagram Classes are the most important building block of any object-oriented system. A class is a description of a set of objects that share the.
Object-Oriented Data Modeling
Object Oriented Analysis: Associations. 2 Object Oriented Modeling BUAD/American University Class Relationships u Classes have relationships between each.
Object Oriented Analysis and Design Class and Object Diagrams.
CSCI-383 Object-Oriented Programming & Design Lecture 10.
Modeling the Static Structure: Relationships ©SoftMoore ConsultingSlide 1.
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
Data Modeling Using the Entity- Relationship (ER) Model.
© Shamkant B. Navathe CC Enhanced Entity-Relationship Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
Chapter 8 Entity-Relationship Modeling Pearson Education © 2009.
CHAPTER 13: OBJECT-ORIENTED DATA MODELING (OVERVIEW) Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi © 2013 Pearson.
Class Diagram Lecture # 1. Class diagram A Class Diagram is a diagram describing the structure of a system shows the system's classes Attributes operations.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys.
1 ODB Design Handling Inheritance in ODL M. Akhtar Ali School of Informatics.
Enhanced Entity-Relationship and UML Modeling. 2.
Object-Oriented Modeling
Visit for more Learning Resources
Object Oriented Analysis and Design
Lec 3: Object-Oriented Data Modeling
UML Class Diagram.
Software Architectures
Enterprise & Application Frameworks
Presentation transcript:

L4-S1Relationships 2003 SJSU -- CmpE Database Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San José State University One Washington Square San José, CA

L4-S2Relationships 2003 SJSU -- CmpE M.E. Fayad 2 Lesson 10: Relationships

L4-S3Relationships 2003 SJSU -- CmpE M.E. Fayad Lesson Objectives 3 Discuss UML Associations Discuss UML – aggregation Understand UML- inheritance Understand How to identify UML Artifacts

L4-S4Relationships 2003 SJSU -- CmpE M.E. Fayad A relationship is a connection among things Three most important relationships in OO –dependencies –generalizations –associations Different kind of lines are used to distinguish various kinds of relationships 4 Relationships

L4-S5Relationships 2003 SJSU -- CmpE M.E. Fayad Dependencies are using relationships State that a change in specification of one thing (the supplier) may affect another thing that uses it (the client), but not necessary the reverse Graphically, it is rendered as a dashed directed line 5 Dependencies (1)

L4-S6Relationships 2003 SJSU -- CmpE M.E. Fayad 6 Dependencies (2) Dependent Class Independent Class Order Book Client Supplier

L4-S7Relationships 2003 SJSU -- CmpE M.E. Fayad An 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. 7 Associations (1)

L4-S8Relationships 2003 SJSU -- CmpE M.E. Fayad Unary association –both ends of an association circle back to the same class Binary association –an association that connects exactly two classes N-ary association –an association that connects more than two classes 8 Types of Association

L4-S9Relationships 2003 SJSU -- CmpE M.E. Fayad Name –an association can have a name, and the name is used to describe the nature of the relationship Role –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 association 9 Associations (2)

L4-S10Relationships 2003 SJSU -- CmpE M.E. Fayad 10 Associations (3) Association Name Person name age address Car model year # of doors registeredCar owner Vehicle Registration Roles Names

L4-S11Relationships 2003 SJSU -- CmpE M.E. Fayad 11 Associations (4) PersonCompany 1..* * Owns by Name employee employer Role Name Multiplicity

L4-S12Relationships 2003 SJSU -- CmpE M.E. Fayad Simple 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 below 12 More on Associations WindowGeomFigure displays0..* CompanyPerson employs0..* EmployerEmployee

L4-S13Relationships 2003 SJSU -- CmpE M.E. Fayad Associations are directed (one way), bidirectional, and undirected. UML makes no distinction between bidirectional and undirected associations. 13 More on Associations Class1Class2 Stereotype RelationName {Constraints} * role1Role2: interface Multiplicity

L4-S14Relationships 2003 SJSU -- CmpE M.E. Fayad Recursive 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. 14 More on Associations

L4-S15Relationships 2003 SJSU -- CmpE M.E. Fayad Directed association is a one-way association, in which one side knows the other, but not vice versa. Multiplicity Specification: –1exactly one –0, 1zero or one –0..4between zero and four –3, 7either three or seven 15 More on Associations

L4-S16Relationships 2003 SJSU -- CmpE M.E. Fayad More 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. 16 More on Associations

L4-S17Relationships 2003 SJSU -- CmpE M.E. Fayad Multiplicity –how many objects may be connected across an instance of an association –can be a range of values or an explicit value exactly one1 zero or one (optional)0..1 zero or more (many)0..* one or more (mandatory)1..* numerically specifiedm..n 17 More Multiplicities

L4-S18Relationships 2003 SJSU -- CmpE M.E. Fayad Recursive associations are associations in which one class is involved. 18 More on Associations Employee name staffNo roomNo Person Patient 1 manager reports to leads office clerk has * * relative

L4-S19Relationships 2003 SJSU -- CmpE M.E. Fayad An n-ary association is like a common (binary) association, except that more than two association roles involved in it. 19 N-ary Association Class1Class2 Class3 N-ary association Ternary association

L4-S20Relationships 2003 SJSU -- CmpE M.E. Fayad 20 More on n-ary Association date trainNo Train carriageNo seatNo Seat name title Passenger Reservation 1 1..* Ternary association

L4-S21Relationships 2003 SJSU -- CmpE M.E. Fayad 21 More on Associations Recursive Associations N-ary Associations Attributed Associations (Association Class) Association Constraints Qualified Associations Derived Associations Directed Associations Ordered Associations Realization/Refinements Dependency

L4-S22Relationships 2003 SJSU -- CmpE M.E. Fayad More on Associations  Associations are usually bidirectional  Allows each object involved in the relationship to refer to the object to which it is related.  Bidirectional association means at the relationship has an inverse.  Associations do not have to be bidirectional. 22

L4-S23Relationships 2003 SJSU -- CmpE M.E. Fayad ManWoman Marriage husband wife ScreenWindow Windows NetsUser Authorization CarTrailer Association Type One-to-One One-to-Many (One-to-Zero-or-More) Many-to-Many Zero or One 23

L4-S24Relationships 2003 SJSU -- CmpE M.E. Fayad SquareLine Sides father mother children Secure Room Person Occupants MaleFemale TraditionalFamily Association Type Specified the # of instances on the “many” side Specify the possible # of instances using “or” Ternary relationship Child 24

L4-S25Relationships 2003 SJSU -- CmpE M.E. Fayad Server Client Connection baudRate protocol wireType disconnect rerouteLink These attributes don’t belong in either the Client or Server class. They are attributes of the connection itself. The association class can have behaviors as well as attributes. Connection Association Class 25

L4-S26Relationships 2003 SJSU -- CmpE M.E. Fayad Aggregation is a special form of association. Aggregation is used when the relationship is “part/whole” or “contains/is-part-of” Aggregation is transitive and operations on “whole” often cascade down to “parts”. 26 Aggregation & Composite

L4-S27Relationships 2003 SJSU -- CmpE M.E. Fayad 27 Aggregation & Composite Server Client Aggregation 52 “whole” “part” Computer CPUDisk Drive KeyboardMouse *

L4-S28Relationships 2003 SJSU -- CmpE M.E. Fayad Special diamond symbol used on “whole” side to indicate aggregation. Aggregation is an anti-symmetric that is, if A is part of B, then B is not part of A. DO NOT confuse aggregation with generalization An essential property of aggregates is that the whole acts as a proxy for its parts. A composition is a strict form of aggregation, in which the parts are existence-dependent on the entirely 28 Aggregation & Composite

L4-S29Relationships 2003 SJSU -- CmpE M.E. Fayad 29 Aggregation 4..* BodyMotorWheel Car Anywhere from four to many Whole Part

L4-S30Relationships 2003 SJSU -- CmpE M.E. Fayad 30 Aggregation & Composite Entirely Existence- DependentPart Part Composition Aggregation

L4-S31Relationships 2003 SJSU -- CmpE M.E. Fayad Mr. Clinton’s hand is part-of Mr. Clinton & Mr. Clinton is part-of U.S.A. Therefore: Mr. Clinton’s hand is part-of U.S.A. 31 Aggregation Problem

L4-S32Relationships 2003 SJSU -- CmpE M.E. Fayad 32 Keypad Number Keys Total KeySubtotal Key Display Drawer display drawer * Cash Register Example

L4-S33Relationships 2003 SJSU -- CmpE M.E. Fayad  Attributes are simply the information associated with the object.  The data type used to hold the attributes is often a fundamental type, such as int or char.  Sometimes the attribute can be a non-fundamental type, such as String type and Address type.  Avoid using attributes which might be better implemented as an association to a new class. 33 Attributes

L4-S34Relationships 2003 SJSU -- CmpE M.E. Fayad x 34 More on Attributes TV String model String serialNum String manName For example: Why? Using an association to a Manufacturer class, the name and address of each manufacturer will be stored in one place rather than in each of the TV objects made by that manufacturer. TV String model String serialNum Manufacturer String name Address address productmanu- facturer Using Attributes Using Association *

L4-S35Relationships 2003 SJSU -- CmpE M.E. Fayad 35 More on Attributes Employee String name float salary long clearanceNum If attributes only make sense in some instances of a given class but not in others. It will make sense to split the single class into two classes or more. Employee String name float salary ClearedEmployee long clearanceNum openVault() Split into two classes Not all employees have clearances inheritance

L4-S36Relationships 2003 SJSU -- CmpE M.E. Fayad A relationship between a general thing (called the superclass or parent) and a more specific kind of that thing (called the subclass or child) –also known as the “is-a-kind-of” relationship A child –is substitutable for the parent –inherits the properties of its parents 36 Generalization (1)

L4-S37Relationships 2003 SJSU -- CmpE M.E. Fayad A class –may have zero, one, or more parents –that has no parents and has one or more children is called a root class or a base class –that has no children is called a leaf class Inheritance –a class with exactly one parent uses single inheritance –a class with more than one parent uses multiple inheritance Graphically, it is rendered as a solid directed line with a large open arrowhead, pointing to the parent 37 Generalization (2)

L4-S38Relationships 2003 SJSU -- CmpE M.E. Fayad When a relationship exists between classes such that lower-level classes (called subclasses) share certain attributes and behaviors which can be defined once in a higher-level class (called superclasses). Subclasses inherit properties (attributes and behaviors) of its superclass and then adds its own unique properties and modifies any inherited properties. This is called Generalization or Inheritance. 38 Inheritance

L4-S39Relationships 2003 SJSU -- CmpE M.E. Fayad 39 Base and Leaf Classes Account LoanChecking Bank book Leaf Class Base Class

L4-S40Relationships 2003 SJSU -- CmpE M.E. Fayad 40 More on Inheritance Window size icon paintWindow bitmaps textWindow contents

L4-S41Relationships 2003 SJSU -- CmpE M.E. Fayad 41 Single and Multiple Inheritance Passenger Car Private CarTaxi Account LoanChecking Bank book Service Multiple inheritance Single inheritance

L4-S42Relationships 2003 SJSU -- CmpE M.E. Fayad 42 Aggregation vs. Inheritance AggregationInheritance Instances of distinct classesInstances of a single class “a-part-of”(APO)“a-kind-of” or “is-a” (AKO) Containssuperclass-of Aggregate + partsSuperclass + subclass “and” relationship“or” relationship Propagated only if specifiedInheritance

L4-S43Relationships 2003 SJSU -- CmpE M.E. Fayad What are the other terms for attributes & operations? Define an object and a class in UML What is an association? Give examples Associations are usually bidirectional. Please describe. Describe the basic difference between aggregation and inheritance. What do they have in common? What do you think “multiple inheritance” means? Which type of association is more likely to yield savings in the amount of code required for implementation? why? Define the process of identifying objects, classes, inheritance, associations & aggregation, attributes, and behaviors Define Polymorphism with examples What do we mean by saying “Model/View/Controller”? 43 Discussion Questions