0% found this document useful (0 votes)
3 views39 pages

ADBMS Chapter 5

The document discusses Object-Oriented Databases (OODB) and Object-Relational Database Management Systems (ORDBMS), highlighting their advantages over traditional relational databases, such as better representation of complex data types and improved handling of real-world entities. It covers key concepts like encapsulation, inheritance, and polymorphism, as well as the Object Definition Language (ODL) and Object Query Language (OQL) used for defining and querying object types. Additionally, it addresses the limitations of relational databases and the integration of object-oriented features into relational systems to create a more flexible and powerful database management approach.

Uploaded by

matias bahiru
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views39 pages

ADBMS Chapter 5

The document discusses Object-Oriented Databases (OODB) and Object-Relational Database Management Systems (ORDBMS), highlighting their advantages over traditional relational databases, such as better representation of complex data types and improved handling of real-world entities. It covers key concepts like encapsulation, inheritance, and polymorphism, as well as the Object Definition Language (ODL) and Object Query Language (OQL) used for defining and querying object types. Additionally, it addresses the limitations of relational databases and the integration of object-oriented features into relational systems to create a more flexible and powerful database management approach.

Uploaded by

matias bahiru
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 39

Object Oriented &

Object Relational
Databases

Chapter 5
Pravicha.M.T
Introduction
Object-Oriented databases are now referred to
as Object Databases (ODB) (previously
called OODB).

Database systems are referred to as Object


Data Management Systems (ODMS)
(formerly referred to as ODBMS or OODBMS).
Introduction
Traditional data models and systems have certain
shortcomings when more complex database
applications must be designed and implemented.
Databases for engineering design and
manufacturing, scientific experiments etc.. have
requirements and characteristics that differ from
those of traditional business applications; the need
for new data types for storing images, videos, or
large textual items;

Object Databases were proposed to meet some


of the needs of these more complex applications.
Introduction
In object databases we can specify both the structure
of complex objects and the operations that can be
applied to these objects.

Increase in the use of object-oriented programming


languages for developing software applications also
lead for the development of ODB.

Newer versions of relational systems have


incorporated many of object database which has led
to database systems that are characterized as object-
relational or ORDBMSs.
Limitations of Relational
Databases
• Poor Representation of “Real World” Entities
– Due to normalization
– Which in turn lead to joins which are costly.

• Semantic Overloading
– Has only one construct to represent data and
relationships between data.---relations
– There is no methods to represent has, owns,
manages relationships

• Limited Operations
– Tuple oriented operations. No new operations can be
defined.
– For e.g: if GIS application uses points,
lines,polygons....& Needs operation for
distance,intersection,....But SQL does not allow.
Limitations of Relational
Databases
• Homogenous Data Structure
– Horizontal and vertical homogeneity
– Intersection of row and column must be an atomic
value.
– Too restrictive to real world objects that have complex
structures

• Difficulty Handling Recursive Queries


• Atomicity of data means that repeating groups are not
allowed in the relational model. As a result,it is
extremely difficult to handle recursive queries that is
queries about realtionships that a relation has with itself.
Object-Oriented Concepts &
Features
Objects  User defined complex data types.

An object typically has two components: state


(value) and behavior (operations).

It can have a complex data structure as well as


specific operations defined by the programmer.

Objects in an OOPL exist only during program


execution; therefore, they are called transient
objects.

An OO database can extend the existence of objects


so that they are stored permanently in a database,
and hence the objects become persistent objects
that exist beyond program termination and can be
retrieved later and shared by other programs.
Object-Oriented Concepts &
Features
An instance variable (in OOPL) is similar to the
concept of an attribute in the relational model,
except that instance variables may be encapsulated
within the object and thus are not necessarily visible
to external users.

Object-oriented systems allow definition of the


operations or functions (behaviour) that can be
applied to objects of a particular type.

Some OO models insist that all operations a user


can apply to an object must be predefined. This
forces a complete encapsulation of objects.
Object-Oriented Concepts &
Features
Complete Encapsulation is not enforced in most OO
data models for two reasons.

First, database users often need to know the


attribute names so they can specify selection
conditions on the attributes to retrieve specific
objects.

Second, complete encapsulation implies that any


simple retrieval requires a predefined operation,
thus making queries difficult to specify on the fly.
Object-Oriented Concepts &
Features
To support encapsulation in ODM, an operation is
defined in two parts.

The first part, called the signature or interface of the


operation, specifies the operation name and
arguments (or parameters).

The second part, called the method or body,


specifies the implementation of the operation.

Operations can be invoked by passing a message to


an object, which includes the operation name and
the parameters. The object then executes the
method for that operation.
Object-Oriented Concepts &
Features
Inheritance: This permits specification of new types
or classes that inherit much of their structure and/or
operations from previously defined types or classes.

This makes it easier to develop the data types of a


system incrementally, and to reuse existing type
definitions when creating new types of objects.

Another OO concept is Polymorphism which is of


two types. Function overloading & Operator
Overloading.
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
 Operator overloading.
 Function overloading
Object Definition in ODB
Objects – User defined complex data types

An object has structure or state (variables) and


methods (behavior/operations)

An object is described by four characteristics

Identifier(OID): a system-wide unique id for an object

Name: an object may also have a unique name in DB


(optional)

Lifetime: determines if the object is persistent or


transient

Structure: Construction of objects using type


constructors
Object Identifier
ODMS provides A unique identity to each
independent object stored in the database.

System-generated object identifier (oid).

Not visible to the external user.

OID is immutable; OID value of a particular


object should not change.

Each OID be used only once.

Every object must have an immutable OID,


whereas a literal value has no OID and its value
just stands for itself.
Object Structure
The state (current value) of a complex object may be
constructed from other objects (or other values) by
using certain type constructors
Object Can be represented by (i, c, v)
◦ i is an unique id
◦ c is a type constructor
◦ v is the object state
For e.g: O1 =(i1,atom,’Arbaminch’)
O2=(i2,atom,’Addis’)
O3=(i4,set,{i1,i2})
Type Constructors
◦ Basic types: atom, tuple and set
◦ Collection type: list, bag and array
Type Constructors
Atom Built in data types such as integers, strings, floating point numbers etc..
Tuple Create standard structured types, such as the tuples.A structured type is
(struct) made up of several components(compound or composite type). More
accurately, struct is a type generator, because many different
structured types can be created.
struct Name<FirstName: string,MiddleInitial: char, LastName: string>
The tuple constructor can create structured values and objects of the
form <a1:i1, a2:i2, ..., an:in>, where each aj is an attribute name and
each ij is a value or an OID. The tuple type constructor is often called
a structured type, since it corresponds to the struct construct in the C
and C++ programming languages.
The type constructors atom and struct are the only ones available in the
original (basic) relational model.
Collection Include the set(T), list(T),bag(T), array(T) type constructors. These
(multivalued allow part of an object or literal value to include a collection of other
) objects or values when needed. These constructors are also considered
to be type generators because many different types can be created.
Type Constructors
Set Create objects or literals that are a set of distinct elements {i1,
i2, ..., in}, all of the same type.
bag is similar to a set except that the elements in a bag need not be
distinct.
list The will create an ordered list [i1, i2, ..., in] of OIDs or values
of the same type. A list is similar to a bag except that the
elements in a list are ordered, and hence we can refer to the
first, second, or jth element.
array Creates a single-dimensional array of elements of the same
type. The main difference between array and list is that a list
can have an arbitrary number of elements whereas an array
typically has a maximum size.
What is Object Oriented Database?
(OODB)
A database system that incorporates all
the important object-oriented concepts
Database + the object oriented
paradigm.
Integration of OO language and
database
Some additional features
Unique Object identifiers
Persistent object handling
Advantages of OODBS
Designer can specify the structure of
objects and their behavior (methods)
Better interaction with object-oriented
languages such as Java and C++
Definition of complex and user-defined
types
Encapsulation of operations and user-
defined methods
ODL
The ODL is a language for defining the specifications
of object types for ODMG compliant systems,
equivalent to the DDL of traditional DBMSs.

Its main objective is to facilitate potability of


schemas between compliant systems while helping
to provide interoperabiltiy between ODBMSs.

The ODL defines the attributes and relationships of


types and specifies the signature of the operations,
but it does not address the implementation of
signatures.

An object definition language (ODL) that


incorporates the preceding type constructors can be
used to define the object types for a particular
database application.
A type or class is defined by assigning it a type
name, and then defining a number of attributes
(instance variables) and operations (methods) for
the type.

PERSON: Name, Address, Birth_date, Age, Ssn

EMPLOYEE: Name, Address, Birth_date, Age, Ssn,


Salary, Hire_date, Seniority

STUDENT: Name, Address, Birth_date, Age, Ssn,


Major, Gpa

EMPLOYEE subtype-of PERSON: Salary,


Hire_date, Seniority

STUDENT subtype-of PERSON: Major, Gpa


Object Query Language
(OQL)
Is a query language proposed for
the object model.
Syntax based on SQL (select,
from, where)
Additional flexibility (queries with
user defined operators and types)
Example of OQL query
Consider a table
Product no Name Color
P1 Ford Mustang Black
P2 Toyota Celica Green
P3 Mercedes SLK Black

The following is a sample query

“what are the names of the black product?”

Select name

From products

Where color = “black”


 Valid in both SQL and OQL, but results are different.
Result of the query (SQL)
Original table
Product no Name Color
P1 Ford Mustang Black
P2 Toyota Celica Green
P3 Mercedes SLK Black
Result
- The statement queries a relational
Name database.
Ford Mustang => Returns a table with rows.
Mercedes
SLK
Result of the query
(OQL)
Original table
Product no Name Color
P1 Ford Mustang Black
P2 Toyota Celica Green
P3 Mercedes SLK Black

Result - The statement


queries a object-
String String
oriented database
Ford Mustang Mercedes
SLK => Returns a
collection of objects.
Comparison
 Queries look very similar in SQL and OQL,
sometimes they are the same
 In fact, the results they give are very different

Query Returns

OQL SQL
Object Tuple
Collection of Table
objects
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.
Object Relational DBMS
Problems with RDBMS
• Restricted built in datatypes (Numbers and strings)
• Structural shortcomings(flat and do not support
nested structures)
• Do not take advantage of OO approaches

Lead to OODBMS

Problems with OODBMS


• Tying database design too closely to application
design
• SQL 92 is productive but needs more resources
• Lack of standard data model leads to errors
Object Relational DBMS
ORDBMS syntesizes the feature of RDBMS with
the best ideas of OODBMS.

New data types and functions can be


implemented using general-purpose languages
such as C and Java.

OO structural features such as inheritance and


polymorphism are part of it.

Example
CREATE TYPE EMP_TYPE AS OBJECT (
empNo NUMBER,
empName VARCHAR2(200),
Address_obj Address_T,
PhoneList_var Phone_T,) NOT FINAL;
Object Relational DBMS
E.g:2

CREATE TYPE Temporary_Employees AS OBJECT

Resume varchar(50) NOT NULL,

) UNDER Emp_type;
User defined Data Types
I. Creating a “type”
Example:

CREATE OR REPLACE TYPE ADDRESS_T AS OBJECT


(
street varchar2(10),
descr varchar(25),
postcode varchar2(7)
)
User defined Data Types
CREATE TYPE PERSON_T AS OBJECT
(
name varchar2(50),
contact address_t
)

CREATE TABLE STUDENT


(
Stud_id varchar2(5) primary key,
Person person_t
)

CREATE TYPE Phone_T AS VARRAY(4) OF VARCHAR2(20);


User defined Data Types
CREATE TYPE STUDENT_T AS OBJECT
(
Stud_id varchar2(5),
Person person_t
)

CREATE TABLE STUDENT OF TYPE STUDENT_T


(
Stud_id primary key,
phone Phone_T
)
User Defined Data
Types
To insert into the table Student

INSERT INTO STUDENT VALUES


(‘ss1111’,
person_t(‘Smith’,address_t(12,’High street’,’Z670101’)));

To refer the individual data items in the abstract data types:

SELECT stud_id, person_t.name, person_t.address_t.street


FROM student
Creating Tables

Creating “Table”
• CREATE TABLE PERSON OF PERSON_TYPE
• CREATE TABLE STUDENT OF
STUDENT_TYPE

UNDER PERSON;
General Way of
Classification
Relational DBMS Object-
Query Relational DBMS

File System Object-Oriented


No Query DBMS

Simple Data Complex Data


Creating “tables” with
“methods”
Implementation
create table slides ( id int,
date date,
caption
document,
picture CD_ image,
method containsName (name
varchar)
returns boolean
)
Creating Tables (Contd.)

create table landmarks(

name varchar (30),

location point);
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”;

You might also like