26
© 2007 by Prentice Hall © 2007 by Prentice Hall 1 Chapter 15 (Web): Chapter 15 (Web): Object-Oriented Object-Oriented Database Development Database Development Modern Database Management Modern Database Management 8 8 th th Edition Edition Jeffrey A. Hoffer, Mary B. Prescott, Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden Fred R. McFadden

© 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

  • View
    220

  • Download
    1

Embed Size (px)

Citation preview

Page 1: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

© 2007 by Prentice Hall© 2007 by Prentice Hall 11

Chapter 15 (Web):Chapter 15 (Web): Object-Oriented Database Object-Oriented Database

DevelopmentDevelopment

Modern Database Modern Database ManagementManagement

88thth Edition EditionJeffrey A. Hoffer, Mary B. Prescott, Jeffrey A. Hoffer, Mary B. Prescott,

Fred R. McFaddenFred R. McFadden

Page 2: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

22Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

ObjectivesObjectives Definition of termsDefinition of terms Create object-oriented database schemas in ODLCreate object-oriented database schemas in ODL Transform UML class diagrams to ODL schemasTransform UML class diagrams to ODL schemas Identify type specifications for attributes, Identify type specifications for attributes,

arguments, and operation return valuesarguments, and operation return values Create objects and specify their attribute valuesCreate objects and specify their attribute values Understand object-oriented database Understand object-oriented database

implementation stepsimplementation steps Understand OQL syntax and semanticsUnderstand OQL syntax and semantics Use OQL to formulate queriesUse OQL to formulate queries Understand object-oriented database applicationsUnderstand object-oriented database applications

Page 3: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

33Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

Object Definition Language Object Definition Language (ODL)(ODL)

Corresponds to SQL’s DDL (Data Corresponds to SQL’s DDL (Data Definition Language)Definition Language)

Specify the logical schema for an Specify the logical schema for an object-oriented databaseobject-oriented database

Based on the specifications of Object Based on the specifications of Object Database Management Group Database Management Group (ODMG)(ODMG)

Page 4: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

44Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

Defining a ClassDefining a Class

classclass–keyword for –keyword for defining classesdefining classes

attributeattribute– – keyword for keyword for attributesattributes

operationsoperations– – return type, return type, name, parameters name, parameters in parenthesesin parentheses

relationshiprelationship– – keyword for keyword for establishing establishing relationshiprelationship

See page 558

Page 5: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

55Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

Defining an AttributeDefining an Attribute

Value can be either: Value can be either: Object identifier OR LiteralObject identifier OR Literal

Types of literalsTypes of literals Atomic–a constant that cannot be decomposed into Atomic–a constant that cannot be decomposed into

componentscomponents Collection–multiple literals or object types Collection–multiple literals or object types Structured–a fixed number of named elements, each of Structured–a fixed number of named elements, each of

which could be a literal or object typewhich could be a literal or object type Attribute rangesAttribute ranges

Allowable values for an attributeAllowable values for an attribute enum–for enumerating the allowable valuesenum–for enumerating the allowable values

Page 6: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

66Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

Kinds of CollectionsKinds of Collections

Set–unordered collection without duplicatesSet–unordered collection without duplicates Bag–unordered collection that may contain Bag–unordered collection that may contain

duplicatesduplicates List–ordered collection, all the same typeList–ordered collection, all the same type Array–dynamically sized ordered collection, Array–dynamically sized ordered collection,

locatable by positionlocatable by position Dictionary– unordered sequence of key-Dictionary– unordered sequence of key-

value pairs without duplicatesvalue pairs without duplicates

Page 7: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

77Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

Defining StructuresDefining Structures

Structure = user-defined type with Structure = user-defined type with componentscomponents

structstruct keyword keyword

Example:Example:struct Address {struct Address {

String street_address;String street_address;

String city;String city;

String state;String state;

String zip;String zip;

};};

Page 8: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

88Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

Defining OperationsDefining Operations

Return typeReturn type NameName Parentheses following the Parentheses following the

namename Arguments within the Arguments within the

parenthesesparentheses

Page 9: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

99Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

Defining RelationshipsDefining Relationships

Only unary and binary relationships allowedOnly unary and binary relationships allowed Relationships are bidirectionalRelationships are bidirectional

implemented through use of implemented through use of inverseinverse keyword keyword ODL relationships are specified:ODL relationships are specified:

relationshiprelationship indicates that class is on many- indicates that class is on many-sideside

relationship setrelationship set indicates that class is on one- indicates that class is on one-side and other class (many) instances unorderedside and other class (many) instances unordered

relationship listrelationship list indicates that class is on one- indicates that class is on one-side and other class (many) instances orderedside and other class (many) instances ordered

Page 10: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

1010Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

Figure 15-1 UML class diagram for a university database

The following slides illustrate the ODL implementation of this UML diagram

Page 11: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

1111Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

Figure 15-2 ODL schema for university database

Page 12: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

1212Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

Figure 15-2 ODL schema for university database (cont.)

class keyword begins the class definition.Class components enclosed between { and }

Page 13: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

1313Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

attribute has a data type and a name

specify allowable values using enum

Figure 15-2 ODL schema for university database (cont.)

Page 14: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

1414Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

extent = the set of all instances of the class

Figure 15-2 ODL schema for university database (cont.)

Page 15: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

1515Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

Operation definition: return type, name, and argument list. Arguments include data types and names

Figure 15-2 ODL schema for university database (cont.)

Page 16: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

1616Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

relationship sets indicate 1:N relationship to an unordered collection of instances of the other class

inverse establishes the bidirectionality of the relationship

Figure 15-2 ODL schema for university database (cont.)

Page 17: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

1717Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

relationship list indicates 1:N relationship to an ordered collection of instances of the other class

Figure 15-2 ODL schema for university database (cont.)

Page 18: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

1818Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

relationship indicates N:1 relationship to an instance of the other class

Figure 15-2 ODL schema for university database (cont.)

Page 19: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

1919Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

In order to capture special features of assignment, this should be converted into two 1:N relationships

Figure 15-3 UML class diagram for an employee project databasea) Many-to-many relationship with an association class

Page 20: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

2020Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

class Employee {(extent employees key emp_id) …………. attribute set <string> skills;};

Note:key indicates identifier (candidate key)

Note: attribute set indicates a multivalued attribute

Figure 15-3 UML class diagram for an employee project database (cont.) b) Many-to-many relationship broken into two one-to-many relationships

Page 21: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

2121Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

class HourlyEmployee extends Employee{ ………….

………….}

Note:extends denotes subclassing

Figure 15-4 UML class diagram showing employee generalization

Page 22: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

2222Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

Figure 15-5 UML class diagram showing student generalization

abstract class Student{ ………….

abstract float calc_tuition();}Note: abstract operation denotes no method (no implementation) of calc_tuition at the Student level

Note: abstract class denotes non-instantiable (complete constraint)

Page 23: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

2323Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

Creating Object InstancesCreating Object Instances Specify a tag that will be the object identifierSpecify a tag that will be the object identifier

MBA699 course ();MBA699 course (); Initializing attributes:Initializing attributes:

Cheryl student (name: “Cheryl Davis”, Cheryl student (name: “Cheryl Davis”, dateOfBirth:4/5/77); dateOfBirth:4/5/77);

Initializing multivalued attributes:Initializing multivalued attributes: Dan employee (emp_id: 3678, name: “Dan Bellon”, Dan employee (emp_id: 3678, name: “Dan Bellon”,

skills {“Database design”, “OO Modeling”});skills {“Database design”, “OO Modeling”}); Establishing links for relationshipEstablishing links for relationship

Cheryl student (takes: {OOAD99F, Telecom99F, Cheryl student (takes: {OOAD99F, Telecom99F, Java99F});Java99F});

Page 24: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

2424Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

Querying Objects in the Querying Objects in the OODBOODB

Object Query Language (OQL)Object Query Language (OQL) ODMG standard languageODMG standard language Similar to SQLSimilar to SQL Some differences:Some differences:

Joins use class’s relationship name:Joins use class’s relationship name: Select x.enrollment from courseofferings x, Select x.enrollment from courseofferings x, x.belongs_to yx.belongs_to y where y.crse_course = where y.crse_course =

“MBA 664” and x.section = 1;“MBA 664” and x.section = 1; Using a set in a queryUsing a set in a query

Select emp_id, name from employees where Select emp_id, name from employees where “Database Design” in skills“Database Design” in skills;;

Page 25: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

2525Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall

Current ODBMS ProductsCurrent ODBMS Products Rising popularity due to:Rising popularity due to:

CAD/CAM applicationsCAD/CAM applications Geographic information systemsGeographic information systems MultimediaMultimedia Web-based applicationsWeb-based applications Increasingly complex data typesIncreasingly complex data types

Applications of ODBMSApplications of ODBMS Bill-of-materialBill-of-material Telecommunications navigationTelecommunications navigation Health careHealth care Engineering designEngineering design Finance and tradingFinance and trading

Page 26: © 2007 by Prentice Hall 1 Chapter 15 (Web): Object-Oriented Database Development Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B. Prescott,

2626Chapter 15-Web © 2007 by Prentice Hall© 2007 by Prentice Hall