object-oriented database systems

26
1 Mapping 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

Upload: martha

Post on 14-Jan-2016

64 views

Category:

Documents


4 download

DESCRIPTION

OBJECT-ORIENTED DATABASE SYSTEMS. 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. OUTLINE. Classes - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: 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

Page 2: 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

Page 3: OBJECT-ORIENTED DATABASE SYSTEMS

3Mapping to OODB Model © 2002 by Dietrich and Urban

ER MODELAbstract Enterprise

Page 4: OBJECT-ORIENTED DATABASE SYSTEMS

4Mapping to OODB Model © 2002 by Dietrich and Urban

UMLAbstract Enterprise

Page 5: OBJECT-ORIENTED DATABASE SYSTEMS

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;

}

Page 6: OBJECT-ORIENTED DATABASE SYSTEMS

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

Page 7: OBJECT-ORIENTED DATABASE SYSTEMS

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}

Page 8: OBJECT-ORIENTED DATABASE SYSTEMS

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

…}

Page 9: OBJECT-ORIENTED DATABASE SYSTEMS

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

Page 10: OBJECT-ORIENTED DATABASE SYSTEMS

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;}

Page 11: OBJECT-ORIENTED DATABASE SYSTEMS

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

Page 12: OBJECT-ORIENTED DATABASE SYSTEMS

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;

}

Page 13: OBJECT-ORIENTED DATABASE SYSTEMS

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;

}

Page 14: OBJECT-ORIENTED DATABASE SYSTEMS

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

Page 15: OBJECT-ORIENTED DATABASE SYSTEMS

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

Page 16: OBJECT-ORIENTED DATABASE SYSTEMS

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;…

}

Page 17: OBJECT-ORIENTED DATABASE SYSTEMS

17Mapping to OODB Model © 2002 by Dietrich and Urban

HOLLYWOOD SCHEMA: EER

Page 18: OBJECT-ORIENTED DATABASE SYSTEMS

18Mapping to OODB Model © 2002 by Dietrich and Urban

HOLLYWOOD SCHEMA: UML

Page 19: OBJECT-ORIENTED DATABASE SYSTEMS

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 … }

Page 20: OBJECT-ORIENTED DATABASE SYSTEMS

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.

Page 21: OBJECT-ORIENTED DATABASE SYSTEMS

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.

Page 22: OBJECT-ORIENTED DATABASE SYSTEMS

22Mapping to OODB Model © 2002 by Dietrich and Urban

CATEGORIES Example: EER

Page 23: OBJECT-ORIENTED DATABASE SYSTEMS

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 )

Page 24: OBJECT-ORIENTED DATABASE SYSTEMS

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.…

}

Page 25: OBJECT-ORIENTED DATABASE SYSTEMS

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.

Page 26: OBJECT-ORIENTED DATABASE SYSTEMS

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( … ) { … }