Ch2 - Object-Oriented Data Modeling
Ch2 - Object-Oriented Data Modeling
Ch2 - Object-Oriented Data Modeling
1
Outlines
• OO vs. EER Data Modeling
• Classes and Objects
• Class Components
• Class and Object Diagram
• Association relationships of different degrees
• Association Class
• Generalization/Specialization
• Polymorphism
– Overriding Inheritance
– Overloading Inheritance
• Multiple Inheritance
• Aggregation and Composition 2
What is Object-Oriented Data Modeling?
• Centers around objects and classes
• Involves inheritance
• Encapsulates both data and behavior
• Benefits of Object-Oriented Modeling
– Ability to tackle challenging problems
– Improved communication between users, analysts,
designers, and programmers
– Increased consistency in analysis, design, and
programming
– Explicit representation of commonality among system
components
– System robustness
– Reusability of analysis, design, and programming results
3
OO vs. EER Data Modeling
Object Oriented EER
Class Entity type
5
State, Behavior, Identity
• State: attribute types and values
• Behavior: how an object acts and
reacts
– Behavior is expressed through operations
that can be performed on it
• Identity: every object has a unique
identity, even if all of its attribute
values are the same
6
UML class and object diagram
a) Class diagram showing two classes
9
Examples of association relationships of different degrees
Unary
Lower-bound – upper-bound
Represented as:
0..1, 0..*, 1..1, 1..*
Similar to minimum/maximum
Binary cardinality rules in EER
Ternary
10
Examples of binary association relationships
a) University example
Alternative multiplicity
representation: specifying the
two possible values in a list
instead of a range
11
Examples of binary association relationships (cont.)
b) Customer Order example
12
Association Class
• An association that has attributes or
operations of its own or that
participates in relationships with
other classes
13
Association class and link object
a) Class diagram showing association classes
Binary association
class with behavior
14
Association class and link object (cont.)
b) Object diagram showing link objects
Association class
instances
15
Ternary relationship with association class
16
Derived attribute, association, and role
Constraint expression for derived attribute
Derived attribute
A patient MUST be
EXACTLY one of the
subtypes Dynamic means a patient can change from
one subclass to another over time
20
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
different classes in different ways
21
Polymorphism, abstract operation,
class-scope attribute, and ordering
Class-scope attributes–only
one value common to all
instances of these classes
(includes default values)
25
Multiple inheritance
26
Aggregation
• Aggregation: A part-of relationship between a
component object and an aggregate object
29
Aggregation and Composition
(b) Object diagram
30
Recursive aggregation
31