Chapter 1 - Concept of Object Oriented Database
Chapter 1 - Concept of Object Oriented Database
(CoSc2042)
Chapter one
Concepts for Object-Oriented Databases
2
Overview of Object-Oriented Concepts
3
Object Structure
The state (current value) of a complex object may be
constructed from other objects (or other values) by using
certain type constructors
Can be represented by (i,c,v)
i is an unique id
c is a type constructor
v is the object state
Constructors
Basic types: atom, tuple and set
Collection type: list, bag and array
4
Type Constructors:
In databases, the state (current value) of a complex object may
be constructed from other objects (or other values) by using
certain type constructors.
The three most basic constructors are atom, tuple, and set.
Other commonly used constructors include list, bag, and array.
5
Object-Oriented Concepts
Abstract Data Types
Class definition, provides extension to complex attribute
types
Encapsulation
Implementation of operations and object structure
hidden
Inheritance
Sharing of data within hierarchy scope, supports code
reusability
Polymorphism:
This refers to an operation's ability to be applied to
different types of objects.
• Operator overloading
6
What is Object Oriented Database? (OODB)
7
Advantages of OODBS
Designer can specify the structure of objects and their
behavior (methods)
8
Object Query Language (OQL)
9
Example of OQL query
The following is a sample query
“what are the names of the black product?”
10
Result of the query (SQL)
Original table
Original table
Product no Name Color
P1 Ford Mustang Black
P2 Toyota Celica Green
P3 Mercedes SLK Black
Query returns:
OQL SQL
Object Tuple
Collection of objects Table
13
SQL3 “Object-oriented SQL”
Foundation for several OO database management systems –
ORACLE8, DB2, etc
New features – “relational” & “Object oriented”
Relational Features – new data types, new predicates, enhanced
semantics, additional security and an active database
Object Oriented Features – support for functions and
procedures
14
User defined Data Types
Creating a “row type”
Example:
create row type AddressType(
street char(50),
city char(20));
15
Creating Data Types (contd.)
Creating “Table”
16
Sample Query
select MovieStar.name,
MovieStar.address.street
from MovieStar
where MovieStar.address.city = “Columbus”;
17
Complex Data and Queries
A Water Resource Management example
A database of state wide water projects
Includes a library of picture slides
Indexing according to predefined concepts – prohibitively
expensive
Type of queries
Geographic locations
Reservoir levels during droughts
Recent flood conditions, etc
18
Complex Data and Queries (contd.)
19
Creating Functions
create function one() returns int4
as ‘select 1 as RESULT'
language 'sql';
answer
20
Creating “tables” with “methods”
Implementation
create table slides (
id int,
date date,
caption document,
picture CD_image,
method containsName
(name varchar)
returns boolean
as external name „matching‟
language „C‟ );
21
Creating Tables (Contd.)
22
Implementation (contd.)
Sample query – find a picture of a reservoir with low water level
which is in “Sacramento”
select P.id
from slides P, landmarks L
where IsLowWaterLevel (P.picture) and
P.containsName (L.name) and L.name =
“Sacramento”;
23