Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 4: Object-Oriented Data Modeling

Similar presentations


Presentation on theme: "Chapter 4: Object-Oriented Data Modeling"— Presentation transcript:

1 Chapter 4: Object-Oriented Data Modeling
Introduction UML Language Object-Oriented Modeling Object Modeling Example Tranform Class Diagram to Relational Database Schema

2 INTRODUCTION Object-oriented data modeling, used in conceptual design, is becoming increasingly popular because of its ability - to represent complex relationships - to represent data and data processing in a consistent notation. This data model includes many concepts similar to those used in EER model, and other modeling facilities.  An object-oriented model is built around objects, just as the ER model is built around entities. An object encapsulates both data and behavior.

3 This approach allows: data modeling and process modeling.
Other advantages: - inheritance - code reuse Phases of object-oriented systems development cycle:        Analysis        Design        Implementation

4 Phases of object oriented modeling development

5 Benefits of object-oriented modeling
 -        Ability to tackle challenging problems -        Improved communication between users, analysts, designers and programmers.  -        Increased consistency in analysis and design (*) -        Robustness of systems -        Reusability of analysis, design and programming results. 

6 Benefits of OO Modeling (cont.)
 ERD and DFD (data flow diagram) During developing DFD, designers have to include so many irrelevant details.  There are abrupt and disjoint transitions among different notations in ER approach.    Object-Oriented approach provides a continuum of representation from analysis to design to implementation, enabling a smooth transition from one model to another.

7 THE UNIFIED MODELING LANGUAGE
UML is a notation/ a specification language that specifies software systems. UML comes from the efforts of three notations:        Booch (1994)        OOSE (Jacobson et al.) 1992        OMT (Rumbaugh et al.) 1991  UML notation is useful for graphically depicting an object-oriented analysis or design model.

8 UML (cont.) UML allows us to represent different views about a system by providing many different diagrams: -      use-case diagram -        class diagram -        state diagram -        interaction diagram -        component diagram -        deployment diagram In database conceptual design, we’ll need only class diagram to represent data and operations of a system.

9 OBJECT-ORIENTED DATA MODELING
Representing Objects and Classes Object: An entity that has a well-defined role in the application domain as well as state, behavior and identity. -        tangible: person, place or thing -        concept or event: department, marriage, registration Objects exhibit BEHAVIOR as well as attributes.  State: attribute types and values  Behavior: how an object acts and reacts.

10 Behavior is expressed through operations that can be performs on it.
 Identity: every object has a unique identity even if all of its attribute values are the same. For example, if there are two Student instances with identical values for all the attributes, they are still two different objects. An object maintains its own identity over its life time. Object class: a set of objects share a common structure and a common behavior.  Example: STUDENT is an object class.

11 Class diagram: Shows the static structure of an object-oriented model: object classes, internal structures and relationships .

12 Object diagram: shows instances that are compatible with a given diagram.

13 Operations Operation: A function or services that is provided by all instances of a class. Types of operations: -        Constructor: creates a new instance of a class. Example: create_student() -        Query: accesses the state of an object that does not alter its state. Example: get_year() -        Update: alters the state of an object. Example: promote_student() Operations implement the object’s behavior.

14 Associations Association: relationship among object classes.
Association role: -        Role of an object in an association -        The end of an association where it connects to a class. Multiplicity -        How many objects participate in an association.  In a class diagram, a multiplicity specification is given as:   lowerbound .. upperbound

15 Examples: 0..* 0 ..1 1..* 1 * 2..6 1,3,5-7 Note: A binary association is bidirectional. The name of an association establishes only one direction.

16 Lower-bound – upper-bound
Represented as: 0..1, 0..*, 1..1, 1..* Similar to minimum/maximum cardinality rules in EER

17 Figure 4-4 – Examples of binary association relationships
(a) University example Alternative multiplicity representation: specifying the two possible values in a list instead of a range

18 (b) Customer order example

19 Representing Association Classes
 An association that has attributes or operations of its own or that participates in relationships with other classes.  Like an associative entity in ER model.

20 Figure 4-6 – Association class and link object
(a) Class diagram showing association classes Unary association with only attributes and no behavior Binary association class with behavior

21 Association or Class We have the option of showing the name of an association class on the association path, or the class symbol. When an association has only attributes but does not have any operations or does not participate in other associations, we should show the name on the association path, to emphasize its “association nature”. When an association has operations of its own, we should display its name in the class rectangle to emphasize its “class nature”.

22 Figure 4-7 –Ternary relationship with association class

23 Derived Attributes, Derived Associations and Derived Roles
A derived attribute, association or role is one that can be computed or derived from other attributes, associations, and roles, respectively. A derived element is shown by placing a slash (/) before the name of the element.

24 Figure 4-8 – Derived attribute, association, and role
Constraint expression for derived attribute Derived attribute Derived relationship (from Registers-for and Scheduled-for) Derived attributes an relationships shown with / in front of the name

25 Generalization/Specialization
Subclass, superclass similar to subtype/supertype in EER Common attributes, relationships, AND operations Disjoint vs. Overlapping Complete (total specialization) vs. incomplete (partial specialization) Abstract Class: no direct instances Concrete Class: direct instances

26 Figure 4-9 – Examples of generalization, inheritance, and constraints
(a) Employee superclass with three subclasses An employee can only be one of these subclasses Shared attributes and operations An employee may be none of them. Specialized attributes and operations

27 (a) Abstract patient class with two concrete subclasses
Abstract indicated by italics A patient MUST be EXACTLY one of the subtypes Dynamic means a patient can change from one subclass to another over time

28 Class-level attribute
 Specifies a value common to an entire class, rather than a specific value for an instance.  Represented by underlining  “=“ is initial, default value

29 Polymorphism Abstract Operation: Defines the form or protocol of the operation, but not its implementation. Method: The implementation of an operation. Polymorphism: The same operation may apply to two or more classes in different ways

30 Figure 4-11 – Polymorphism, abstract operation, class-scope attribute, and ordering
This operation is abstract…it has no method at Student level Class-scope attributes – only one value common to all instances of these clases Methods are defined at subclass level

31 Overriding Inheritance
Overriding: The process of replacing a method inherited from a superclass by a more specific implementation of that method in a subclass. For Extension: add code. For Restriction: limit the method. For Optimization: improve code by exploiting restrictions imposed by the subclass.

32 Figure 4-12 – Overriding inheritance
Restrict job placement

33 Multiple Inheritance Multiple Classification: An object is an instance of more than one class. Multiple Inheritance: A class inherits features from more than one superclass.

34 Figure 4-13 Multiple inheritance

35 Aggregation Aggregation: A part-of relationship between a component object and an aggregate object. Composition: A stronger form of aggregation in which a part object belongs to only one whole object and exists only as part of the whole object. Recursive Aggregation: composition where component object is an instance of the same class as the aggregate object.

36 Figure 4-14 – Example aggregation

37 Figure 4-15 – Aggregation and Composition
(a) Class diagram (b) Object diagram

38 Figure 4-16 – Recursive aggregation

39 Business Rules See chapters 3 and 4
Implicit and explicit constraints on objects – for example: cardinality constraints on association roles ordering constraints on association roles Business rules involving two graphical symbols: labeled dashed arrow from one to the other Business rules involving three or more graphical symbols: note with dashed lines to each symbol

40 Figure 4-17 – Representing business rules
Three-symbol constraint Two-symbol constraint

41 Figure 4-18 – Class diagram for Pine Valley Furniture Company

42 OBJECT MODELING EXAMPLE: THE PINE VALLEY FURNITURE COMPANY
 We do not have to put explicit identifiers for each class since each object will have its own object identity. ER model and relational model use value-based identification (Explicit identification) OO model uses existence-based identification (Implicit identification) In OO model, the identifiers that we should create are the identifier attributes that are meaningful in the application. Example: Salesperson_ID, Customer_ID, …

43 And we should not create the identifiers that are not meaningful attributes in real life.
Example: ProductLine_ID, Vendor_ID, Skill_ID Note: In a conceptual object-oriented model, an attribute should be single-valued. Therefore, a multivalued attribute should be transformed into a separate class and an 1:N association between the class and the new class.

44 TRANSFORM CLASS DIAGRAM TO RELATIONAL DATABASE SCHEMA
In general, the transformation of class diagram to relational schema is similar to that of EER to relational schema, except some specific issues. 1.  Transform a class in class diagram to a table 2.  Transform an attribute of a class to a table column. 3.  In case a class does not have any explicit identifier, create a primary key (usually of integer type) for the table corresponding to that class. 4.  For a table corresponding to a subclass, use the primary key of its superclass as its primary key.

45 5.  For a table corresponding to an association class, create a primary key for it. Besides, put primary keys of the tables corresponding to the participant classes as its foreign keys.  6.  For a component class in an aggregate association, its table takes primary key of the table corresponding to its aggregate class as a part of its primary key.  7.  Transforming a binary or ternary association into a relational schema strongly resembles the transformation of the EER relationship.  8.  Represent the operations of a class as stored procedures or functions. These functions/ procedures may contains some SQL commands. 9.  There is no good way to represent multiple inheritance in a relational schema. Restructure the class diagram to avoid it.


Download ppt "Chapter 4: Object-Oriented Data Modeling"

Similar presentations


Ads by Google