the object database

25
--The Object Database-- 1 The Object Database Object databases integrate database technology with the object-oriented paradigm In object databases, each entity of the real world is represented by an object. Classical examples of objects are: Electronic components, designed using a Computer Aided Design (CAD) system; Mechanical components, designed using a Computer Aided Manufacturing (CAM) system; Specifications and programs, managed in a Computer Aided Software Engineering (CASE) environment; Multimedia documents, which includes text, images and sound, managed by multimedia document managers.

Upload: roddy

Post on 14-Jan-2016

57 views

Category:

Documents


1 download

DESCRIPTION

The Object Database. Object databases integrate database technology with the object-oriented paradigm In object databases, each entity of the real world is represented by an object. Classical examples of objects are: Electronic components, designed using a Computer Aided Design (CAD) system; - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: The  Object Database

--The Object Database-- 1

The Object Database

Object databases integrate database technology with the object-oriented paradigm

In object databases, each entity of the real world is represented by an object. Classical examples of objects are: Electronic components, designed using a Computer Aided

Design (CAD) system; Mechanical components, designed using a Computer Aided

Manufacturing (CAM) system; Specifications and programs, managed in a Computer Aided

Software Engineering (CASE) environment; Multimedia documents, which includes text, images and

sound, managed by multimedia document managers.

Page 2: The  Object Database

--The Object Database-- 2

Non-1NF Date

Consider the table shown below.

--------------------- ACME | part | place | ------|------

| liquor| Paris

| engine| Paris

| ----------|----------------

DELCO | part | place

| ------|------

| engine| Rome

....

Page 3: The  Object Database

--The Object Database-- 3

Un-nest and Normalise Table

The relational database solution - unnest

Normalize if necessary ACME appears twice What happened to structure?

supplier | part | Place --------------------- ACME | liquor | Paris

ACME | engine | Paris

DELCO | engine | Rome

....

Page 4: The  Object Database

--The Object Database-- 4

A Data Structures Solution

Imagine a nested record structure

Variable-sized records are difficult to maintain How to select? No tuples, so what is the key? Pointers are memory-only, how to store?

Supplier Parts-list Parts

-------- --------- ------------------

|ACME | | part1 ------> | liquor | Paris |

| | | | ------------------

| parts-----------> | | ------------------

| | | part2 ------> | engine | Rome |

-------- ---------

Page 5: The  Object Database

--The Object Database-- 5

A Rectangle Data Type

Database stores rectangles as four points What does the following query do?

SELECT * FROM R, S

WHERE NOT(R.upperLeftX > S.lowerRightX OR S.upperLeftX > R.lowerRightX OR

R.upperLeftY < S.lowerRightY OR S.upperLeftY < R.lowerRightY);

What does the following query do?

SELECT * FROM R, S

WHERE rectangle.overlaps(R, S);

Page 6: The  Object Database

--The Object Database-- 6

Abstract Data Type (ADT)

SQL has limited data types New data types are useful

Polygons Images Sounds video

Data type needs specifications for Structure Operations Implementation Optimization, e.g., indexing

Page 7: The  Object Database

--The Object Database-- 7

O-O Concepts - Object

Object A uniquely identifiable entity that contains both the attributes

that describe the state of a ‘real world’ object and the actions that are associated with it.

Encapsulates state Instance variables or attributes Complete encapsulation – can’t look inside and access

variables (public vs. private) Encapsulates behavior

Operations Signature (specification) vs. method (implementation)

Page 8: The  Object Database

--The Object Database-- 8

O-O Concepts, cont.

Method Block of code Object performs method on self Constructor, destructor

Message Communicates request to an object Parameters can be passed

Class Blueprint for object An object is an instance of a class

Inheritance Superclasses, subclasses, overloading

Page 9: The  Object Database

--The Object Database-- 9

Definitions

OODMA logical data model that captures the semantics of objects

supported in object-oriented programming.

OODBA persistent, sharable collection of objects defined by an OODM.

OODBMSThe manager of an OODB

Page 10: The  Object Database

--The Object Database-- 10

Why OODB?

From programming language point of view: permanent storage of objects (languages just support objects

in memory) sharing of objects among programs fast, expressive queries for accessing data version control for evolving classes and multi-person projects

Page 11: The  Object Database

--The Object Database-- 11

Why OODB?

From database point of view: More expressive data types (traditional DBs provide limited predefined

types) e.g., a desktop publishing program might model a page as a series

of frames containing text, bitmaps, and charts need composite and aggregate data types (e.g., structures and

arrays) More expressive data relationships

many-to-one relationship (e.g., many students in one class) navigating across relationship links

More expressive data manipulation SQL is relationally complete but not computationally complete i.e.,

great for searching for lousy for anything else– leads to use of conventional programming language plus SQL-

interface– overhead of mapping from SQL to conventional languages

Better integration with programming languages (esp. OO languages)

Encapsulation of code with data

Page 12: The  Object Database

--The Object Database-- 12

Two Object-oriented Approaches

Object-oriented (OODBMS) Hellerstein - “to add DBMS capabilities to an O-O language” Persistence, object lives beyond program execution

PJava - persistent JavaSeveral commercial products

Object-relational (ORDBMS) Hellerstein - “extends a relational database with O-O features” Rich data types

InheritanceSeveral commercial vendors, SQL3

Page 13: The  Object Database

--The Object Database-- 13

OODBMS

Advantages Removes impedance mismatch Long-lived transactions Enriched modeling

Disadvanatages Lack of universal query language Lack of agreed upon standard Performance depends on class definition

Page 14: The  Object Database

--The Object Database-- 14

ODMG 2.

Object Database Management Group Consortium of Vendors: O2, ObjectStore, etc. Standard for OODBMS

PortabilityInteroperabilityComparisonOptimization

Object model ODL OQL

Page 15: The  Object Database

--The Object Database-- 15

Object Model

Atomic object Any user-defined object Class definition

Properties (attributes and structure)(Binary) Relationships (to other objects)Operations

Collection object Set, array, list, etc. Built-in

Interface (virtual object) Inheritance

Multiple inheritance only from interfaces

Page 16: The  Object Database

--The Object Database-- 16

Object Model, cont.

Extent – named, persistent collection of objects of the same class/type One predefined extent for each class

Key Unique for extent

Factory object Constructor

Page 17: The  Object Database

--The Object Database-- 17

Example

Class Person { extent persons key ssn } { attribute struct { string first, string last } name; attribute integer ssn relationship Factory worksIn inverse Factory::employeeOf relationship set<Person> parentOf inverse Person::childOf; relationship set<Person> childOf inverse Person::parentOf };

Page 18: The  Object Database

--The Object Database-- 18

Mapping EER to ODL

Entity type -> class definition Attribute -> attribute

Many-valued -> set attributeComposite -> struct attributeKey -> key

Weak entity type Composite, multi-valued attribute in owning entity type Alternative, map to class

Inheritance Simple, use class inheritance

Page 19: The  Object Database

--The Object Database-- 19

Mapping EER to ODL, cont.

Relationship types Binary (no attributes)

Add relationship attributes to each sideUse sets for many

Ternary or with attributesMap to separate class

Page 20: The  Object Database

--The Object Database-- 20

OQL

SQL-like SELECT-FROM-WHERE

FROM clause is only major difference Iterator variables

p in PersonPerson pPerson as p

Path expressions (can appear in any clause)“dot” notationp.ssnValue of attribute ssn in object denoted by iterator variable

pSame notation for following relationships (few joins!)p.parentOf.ssn

Page 21: The  Object Database

--The Object Database-- 21

Examples

What are the social security numbers of people?SELECT s

FROM person p,

p.ssn s;

What are the social security numbers of children? SELECT s

FROM person p,

p.childOf.ssn s;

AlternativelySELECT s

FROM person.childOf.ssn s;

Page 22: The  Object Database

--The Object Database-- 22

Examples

Create a structure for each social security number and last name of a grandchild whose first name is ‘Frank’.SELECT struct(last_name: g.name.last,

ssn: g.ssn)

FROM person p,

p.childOf c,

c.childOf g

WHERE g.name.first = ‘Frank’;

Page 23: The  Object Database

--The Object Database-- 23

ORDBMS: Third Generation Manifesto

Rich type system Inheritance is a good idea Use primary key when available Rules (triggers, constraints) are a major feature Database access via SQL, usually embedded SQL3

Parts have been released, Oracle supports some SQL3 features Collections Recursion

Page 24: The  Object Database

--The Object Database-- 24

SQL3 DDL

ExampleCREATE TABLE Student

(name VARCHAR(30),

image GIF,

phone setof{INTEGER},

);

Phone is a set GIF is a user-defined data type

Page 25: The  Object Database

--The Object Database-- 25

Multimedia databases

Types of multimedia data Images Audio Video Documents

Queries on multimedia data While the coding of multimedia data is a general problem, the

ability to query large amounts of multimedia data is a more specific problem of multimedia databases.

In general, it is possible to select a multimedia object only in probabilistic terms.