Docsity

Object-Oriented Database Management Systems: An Overview of ODMG, ODL, and OQL, Study notes of Deductive Database Systems

Partial preview of the text

Download Object-Oriented Database Management Systems: An Overview of ODMG, ODL, and OQL and more Study notes Deductive Database Systems in PDF only on Docsity!

Ob ject-Oriented DBMS's

 ODMG = Ob ject Data Management Group: an OO standard for databases.

 ODL = Ob ject Description Language: design in the OO style.

 OQL = Ob ject Query Language: queries an OO database with an ODL schema, in a manner similar to SQL.

ODL Overview

 Class declarations (interfaces).

 Interface includes:

  1. Name for the interface.
  2. Key declaration(s), which are optional.
  3. Extent declaration = name for the set of currently existing ob jects of a class.
  4. Element declarations. An element is an attribute, a relationship, or a metho d.

ODL Relationships

 Only binary relations supp orted.

F Multiway relationships require a \connecting" class, as discussed for E/R mo del.

 Relationshi ps come in inverse pairs.

F Example: \Sells" b etween b eers and bars is represented by a relationship in bars, giving the b eers sold, and a relationship in b eers giving the bars that sell it.

 Many-many relationships have a set typ e (called a col lection type) in each direction.

 Many-one relationships have a set typ e for the one, and a simple class name for the many.

 One-one relations have classes for b oth.

Beers-Bars-Drinkers Example

interface Beers { attribute string name; attribute string manf; relationship Set servedAt inverse Bars::serves; relationship Set fans inverse Drinkers::likes; }

 An element from another class is indicated by ::

 Form a set typ e with Set.

interface Drinkers { attribute string name; attribute Struct Bars::Addr address; relationship Set likes inverse Beers::fans; relationship Set frequents inverse Bars::customers; }

 Note reuse of Addr typ e.

ODL Typ e System

 Basic typ es: int, real/ oat, string, enumerated typ es, and classes.

 Typ e constructors: Struct for structures and four col lection types : Set, Bag, List, and Array.

Limitation on Nesting

class collecti on

Relationship

Attribute

basic, no class

struct collecti on

Example: Multiway Relationship

Consider a 3-way relationship bars-b eers-prices. We have to create a connecting class BBP.

interface Prices { attribute real price; relationship Set toBBP inverse BBP::thePrice; } interface BBP { relationship Bars theBar inverse ... relationship Beers theBeer inverse ... relationship Prices thePrice inverse Prices::toBBP; }

 Inverses for theBar, theBeer must b e added to Bars, Beers.

 Better in this sp ecial case: make no Prices class; make price an attribute of BBP.

 Notice that keys are optional.

F BBP has no key, yet is not \weak." Ob ject identity suces to distinguish di erent BBP ob jects.

Roles in ODL

Names of relationships handle \roles."

Example: Sp ouses and Drinking Buddies

interface Drinkers { attribute string name; attribute Struct Bars::Addr address; relationship Set likes inverse Beers::fans; relationship Set frequents inverse Bars::customers; relationship Drinkers husband inverse wife; relationship Drinkers wife inverse husband; relationship Set buddies inverse buddies; }

 Notice that Drinkers:: is optional when the inverse is a relationship of the same class.

Keys in ODL

Indicate with key(s) following the class name, and a list of attributes forming the key.

 Several lists may b e used to indicate several alternative keys.

 Parentheses group memb ers of a key, and also group key to the declared keys.

 Thus, (key(a 1 ; a 2 ; : : : ; an )) = \one key consisting of all n attributes." (key a 1 ; a 2 ; : : : ; an ) = \each ai is a key by itself."

Example

interface Beers (key name) { attribute string name ...

 Remember : Keys are optional in ODL. The \ob ject ID" suces to distinguish ob jects that have the same values in their elements.

Example: A Multiattribute Key

interface Courses (key (dept, number), (room, hours)) { ...

ODL Class Without Relationships

 Problem: ODL allows attribute typ es built from structures and collecti on typ es.

 Structure: Make one attribute for each eld.

 Set: make one tuple for each memb er of the set. F More than one set attribute? Make tuples for all combinations.

 Problem: ODL class may have no key, but we should have one in the relation to represent \OID."

Example

interface Drinkers (key name) { attribute string name; attribute Struct Addr {string street, string city, int zip} address; attribute Set phone; }

name street city zip phone

n 1 s 1 c 1 z 1 p 1 n 1 s 1 c 1 z 1 p 2

 Surprise: the key for the class (name) is not the key for the relation (name, phone). F name in the class determines a unique ob ject, including a set of phones.

F name in the relation do es not determine a unique tuple.

F Since tuples are not identical to ob jects, there is no inconsistency!

 BCNF violati on: separate out name-phone.

Example

interface Drinkers (key name) { attribute string name; attribute string addr; relationship Set likes inverse Beers::fans; relationship Beers favorite inverse Beers::realFans; relationship Drinkers husband inverse wife; relationship Drinkers wife inverse husband; relationship Set buddies inverse buddies; }

Drinkers(name, addr, b eerName, favBeer, wife, buddy)

 Not in BCNF; decomp ose to:

Drinkers(name , addr, favBeer, wife) DrBeer(name , beer ) DrBuddy(name , buddy)