Download - OBJECT-ORIENTED DATABASE SYSTEMS
1Mapping to OODB Model © 2002 by Dietrich and Urban
Mapping Object-Oriented
Conceptual Models
to the Object-Oriented Data Model
Susan D. Urban and Suzanne W. Dietrich
Department of Computer Science and Engineering
Arizona State University
Tempe, AZ 85287-5406
OBJECT-ORIENTED DATABASE SYSTEMS
2Mapping to OODB Model © 2002 by Dietrich and Urban
OUTLINE
Classes Relationships and Associations Class Hierarchies Shared Subclasses Categories Interface Classes
3Mapping to OODB Model © 2002 by Dietrich and Urban
ER MODELAbstract Enterprise
4Mapping to OODB Model © 2002 by Dietrich and Urban
UMLAbstract Enterprise
5Mapping to OODB Model © 2002 by Dietrich and Urban
OBJECT DEFINITION LANGUAGE: ODL Syntax Summary
class className extends superclassName( extent extentName key keyName){ attribute <attributeType> attributeName;
… relationship <relationType> relationName
inverse <inverseSpec>;…method_definitions;
}
6Mapping to OODB Model © 2002 by Dietrich and Urban
CLASSESSingle-valued Attributes
Create an ODL class including the simple attributes of the class. Composite attributes are represented using a structured type. Declare an extent and specify key attributes of the extent. Derived attributes are defined using a get method call.
EER UML
7Mapping to OODB Model © 2002 by Dietrich and Urban
SINGLE-VALUED ATTRIBUTES Example
struct CompositeStruct {string attrA1;string attrA2;string attrA3; };
class A( extent extentOfA key keyOfA){ attribute string keyOfA; attribute string attrOfA; attribute CompositeStruct compositeOfA;
… // define method here for derivedAttr}
8Mapping to OODB Model © 2002 by Dietrich and Urban
CLASSESMulti-valued Attributes
EER
UML
// Multi-valued attributes are defined using a collection type.
class C ( … ){ … attribute set<String> multiValuedAttr; // Choose appropriate collection type: set, bag, list
…}
9Mapping to OODB Model © 2002 by Dietrich and Urban
ASSOCIATIONS WITHOUT ATTRIBUTES
Use appropriate inverse relationships between the classes involved in the association.
EER UML
10Mapping to OODB Model © 2002 by Dietrich and Urban
ASSOCIATIONS WITHOUT ATTRIBUTES Example
class B( extent extentOfB
key keyOfB){ …
relationship C bTOc inverse C::cTOb;}class C( extent extentOfC
keyOfC){ …
relationship B cTOb inverse B::bTOc;}
11Mapping to OODB Model © 2002 by Dietrich and Urban
ASSOCIATIONS WITH ATTRIBUTES
Create a class to represent the association, known as the association class, with appropriate attributes in the association class and bi-directional inverse relationships with the classes that participate in the association.
EER UML
12Mapping to OODB Model © 2002 by Dietrich and Urban
ASSOCIATIONS WITH ATTRIBUTES Example
class A(…){ …
relationship set<AB> aTOab inverse AB::abTOa;}
class B( … ){ …
relationship set<AB> bTOab inverse AB::abTOb;}
class AB( extent extentOfAB){ attribute string attrOfAB;
relationship A abTOa inverse A::aTOab;relationship B abTOb inverse B::bTOab;
}
13Mapping to OODB Model © 2002 by Dietrich and Urban
RECURSIVE ASSOCIATIONS
EER UML
//Use inverse relationships within the same class.class B( extent extentOfB
key keyOfB){ …
relationship B parent inverse B::child; relationship set<B> child B::parent;
}
14Mapping to OODB Model © 2002 by Dietrich and Urban
NAVIGATIONUni-directional Associations
//Use an attribute with a class as a type.class B( extent extentOfB
key keyOfB){ …
attribute C bc;}
EER UML
15Mapping to OODB Model © 2002 by Dietrich and Urban
WEAK OR QUALIFIED ASSOCIATION
Create a class for the weak class with a composite key that includes the key of the owner class. The weak class can also include a relationship to the object of the owner class.
UMLEER
16Mapping to OODB Model © 2002 by Dietrich and Urban
WEAK OR QUALIFIED ASSOCIATION Example
class A( extent extentOfA
key keyOfA){ attribute string keyOfA;
relationship set<Weak> linkToWeak inverse Weak::linkToOwner; …}class Weak ( extent extentOfWeak
key (partialKey, keyOfA)) { attribute string partialKey;
attribute string keyOfA;relationship A linkToOwner inverse A:: linkToWeak;…
}
17Mapping to OODB Model © 2002 by Dietrich and Urban
HOLLYWOOD SCHEMA: EER
18Mapping to OODB Model © 2002 by Dietrich and Urban
HOLLYWOOD SCHEMA: UML
19Mapping to OODB Model © 2002 by Dietrich and Urban
CLASS HIERARCHIES
The inheritance of state and behavior is supported by the extends clause in ODL.
Example
class Person( … ){ …}
class MovieProfessional extends Person( … ) { // Specific properties and methods for MovieProfessional … }
class Celebrity extends Person( … ) { // Specific properties and methods for Celebrity … }
20Mapping to OODB Model © 2002 by Dietrich and Urban
SHARED SUBCLASSES
Multiple inheritance of both state and behavior is not directly supported. An interface defines behavior, which can be inherited in addition to the inheritance through the extends clause.
21Mapping to OODB Model © 2002 by Dietrich and Urban
CATEGORIES
Create a class for the category class. Create uni-directional attributes that point to the classes that
define the category class. For each instance of the category class, only one of the uni-
directional attributes will have a value (to indicate the type of the category object). The other uni-directional attribute(s) will always be null.
22Mapping to OODB Model © 2002 by Dietrich and Urban
CATEGORIES Example: EER
23Mapping to OODB Model © 2002 by Dietrich and Urban
CATEGORIESExample: UML
In UML, the category mapping also applies to the use of XOR Constraints (similar to partial or total EER category )
24Mapping to OODB Model © 2002 by Dietrich and Urban
CATEGORIES Example: Sponsor Mapping
class Person( extent Persons
key …){ … }class Company( extent Companies
key …){ … }class Sponsor( extent Sponsors){ attribute Person personSponsor; //Can also be implemented as bi-directional
attribute Company companySponsor; //relationships for total categories.…
}
25Mapping to OODB Model © 2002 by Dietrich and Urban
INTERFACE CLASSES
Create an interface in ODL.
Subclasses of the interface are defined to implement the interface class.
26Mapping to OODB Model © 2002 by Dietrich and Urban
INTERFACE CLASSES Example
interface Business(…){ …
string getTaxPayerId(…);void setTaxPayerId(…);integer calcTotalIncome(…);}
class Person( … ) { … }
class Company: Business( … ) { … }
class SelfEmployedPerson extends Person: Business( … ) { … }