tuples of a relation.

handprintΛογισμικό & κατασκευή λογ/κού

18 Νοε 2013 (πριν από 3 χρόνια και 8 μήνες)

77 εμφανίσεις

Object oriented database (OODB):
-


Object oriented database (OODB) are dependent on
the object oriented programming paradigm. It enable
us to create classes, organize object, structure an
inheritance hierarchy and call methods of other classes.
Beside these it also provides the facilities associated
with standard database systems. However object
oriented database system have not yet replaced the
RDBMS in commercial business applications.



Although a relational database can be used to store and manage object, it
does not understand objects as such. Therefore, a middle layer called object
manager or object
-
oriented layer software is required to translate object into
tuples of a relation.

Different approaches for designing an object oriented
database;

a)
Designed to store, retrieve and manage objects
created by programs written in some object oriented
languages (OOL) such as C++ or Java.

b)
Designed to provide object oriented facilities to user of
non object
-
oriented programming languages (OOPLs)
such as C or Pascal




The user will create classes, objects, inheritance
hierarchy, and so on and the database system will
store and manage these objects and classes. This
second approach, thus turns non
-
OOPLs into OOPLs.
A translation layer is required to map the object
created by user into objects of the database system



Storing and Accessing objects:
-


The data part of all objects of a class are stored individually in a
database. The program part of the class are stored as part of the
database schema along with the type definitions of the classes
Objects can also be given names to allow their access. However,
such an approach will not work hen the number of objects in a
database are large in numbers say in the range of millions. Another
method is to collect object into a group. a group is given a name.
The programs will then iterate over a group to find out the required
object.




A special case of a collection is the class
-
extent. A class
-
extent is
the objects belonging is the collection of all the objects belonging to
a class. Whenever a new object needs to inserted be inserted into a
class it is inserted into its class
-
extent automatically. Similarly,
whenever a new object need to be deleted, it is deleted from the
respective class extent.



A sample object oriented database:
-

A sample object oriented is shown in figure

The solid lines(
-
) in the figure represents class
-
subclass link. The dash(
---
) represents attribute
domain link. The class vehicle is the root of a
class composition hierarchy that involves vehicle
specs and company. The class vehicle is also
the root of a class hierarchy that involves the
subclasses two wheeler and four wheeler. The
class company is in turn the root of a class
hierarchy that involves the subclasses Domestic
company and foreign company. It is also the root
of a class composition hierarchy that involve the
class employees

Object Oriented Database (OODB):
-

Code

Color

Specifications

Manufacturer

Vehicle

Length

Width

Height

Type

Fuel


Vehicle specs

Gear

Seating type

Two Wheeler

Gear

Seating type

No_ of_ doors

Company _name

President

Place

Four Wheeler

Company

Emp _Code

Emp_ Name

Age

Employee

Dom _Com_ name

Dom_ president

Dom Place

For _Com_ name

For_ president

For Place

Domestic company

Foreign Company

Advantages of OODBMS over RDBMS:
-


a)
RDBMS does not allow nested structure. nested structure
applications are found in CAD/CAE, aerospace science, etc. It is
easier to navigate through these complex structures in the firm of
objects rather than in the from of table and records.


b)
Relational database have only a limited number of data type like
integer, char, text, etc. although we can create complex data
types in relational database by combining fields, these are
restricted by their base data type and sub classing with
inheritance.


c)
Object oriented database are favored in those application where
the relationship among data elements are more important than
data items themselves. However, relational database are used in
those applications where the values of data elements are more
important. If a record makes sense only when used in context of
other records, then an object oriented database would be more
appropriate.


Distributed DBMS(DDBMS):
-

Some organization use distributed database
system rather than a centralized database. In
the centralized database system data resides in
one single location. But in a distributed database
system, database is stored in several
computers. The computers in a distributed
system communication and exchange data
among one other using leased lines, telephone
lines or other means of communication. These
computers do not share memory or clock. Each
of the computers in a distributed system.
Participates in the execution of transactions.
These computer can also be known as sites or
nodes.

Advantages of distributed database:
-

a)
Data sharing: since data is distributed on multiple computers,
user operating on one computer can work on data available on
any another computer.

b)
Distributed control:
-

unlike centralizes database system, where a
single database administrator controls the database, in a
distributed system responsibility of control is divided among local
administrators for each computer thus local administrators have a
certain degree of control over the database stored locally.

c)
Reliability and Availability:
-

Even if one site fails in the distributed
system the remaining site can continue working. If data is
replicated among multiple computers, failure of any one computer
does not case shutdown of the entire database system

d)
Faster Query processing:
-

Queries involving data at several sites
can be split into sub queries can then be executed in parallel by
several sites, such a parallel computation allows faster
processing.

Disadvantages of distributes database:
-

a)
Increase cost:
-

it is more difficult to develop software
packages to implement distributed database system.
Also cost involved in physically linking different sites

b)
More Error prone:
-
since the sites that comprise
distributed database system operate in parallel, it is
very difficult to ensure the correctness of data. The
algorithms are more error prone and have greater
potential for bugs,

c)
Increased overhead:
-

maintaining physical links
between the sites and exchanging messages among
computer is an additional overhead associated with
distributed systems that are absent in the case of
centralized system


Advantages of DBMS:
-

a)
It represents complex relationships among different
data items.

b)
Keeps tight control on data redundancy.

c)
Enforces user defined rules to ensure the integrity of
data in a table from.

d)
Maintains data dictionary for the storage of information
pertaining to data fields and data manipulation.

e)
Ensure that data can be shared across all applications.

f)
Enforces data access authorization

g)
Has an automatic intelligent backup and recovery
procedure of data.

h)
Has different interfaces through which user can
manipulated data.

Object Oriented database:
-

Different Flavors of ORACLE available


Relational:
-

The traditional ORACLE relation Database (RDBMS).


Object
-
relational:
-

The traditional ORACLE relational database,

Extended to include Object
-
oriented concepts and structures such as

abstract data type, nested tables, and varying arrays


Familiarity with the function and features of the core Oracle relational
database


Object
-
oriented:
-

An object
-
oriented database whose design in based

solely on Object
-
Oriented Analysis and Design principles


OO capabilities are used the functions and data types available in oracle
as well as its programming languages( SQL and Pl/SQL).



Why should objects be used:
-

Object reduce complexity by giving an intuitive way of representing
complex data and its relations.

Besides simplifying the interaction with data, object may help in other
ways.

OO features are:
-

Object reuse

Standards adherence

Object types:
-

Abstract Data type:
-

abstract data types is a data type that consists of
one or more subtypes

Example:
-

address

Street Vrachar2(50)

City Varchar2(25)

State Varchar2(25)

Zip Number


Naming conventions for objects:
-

When working with OO the following rules should
be enforced:

1)
Table and column name will be Singular(such
as EMPLOYEES, Name, and State)

2)
Abstract data type name will be singular nouns
with a _TY suffix (such as PERSON_TY or
ADDRESS_TY)

3)
Table and Data type name will always be
uppercase (such as EMPLOYEE OR
PERSON_TY).

Create type address_ty as object

(street varchar2(50),

city varchar2(25),

state varchar2(25),

zip number);


Create type command note the as object clause. The as object clause explicitly
identifies address_ty as an OO implementation.



Create type person_ty as object

(name varchar2(25), address address_ty);


The following command creates a table named customer. A customer has a
cutomer_id and all the attributes of a person ( via the person_ty datatype)


create table customer

(customer_id number,person person_ty);


desc customer;


desc person_ty;



desc address_ty;

select column_name,data_type from user_tab_columns


select column_name,data_type from user_tab_columns

where table_name='CUSTOMER';


select attr_name,length,attr_type_name from user_type_attrs where
type_name='PERSON_TY';


select attr_name,length,attr_type_name from user_type_attrs where
type_name='ADDRESS_TY';


Inserting records into the Customer table


insert into customer values(1,
person_ty('Mahesh',address_ty('Dadar','Mumbai','Maharashtra',416313)));


insert into customer values(2,
person_ty('Vaishali',address_ty('Kurla','Mumbai','Maharashtra',416315)));


select customer_id from customer;


select * from customer;


select customer_id,client.person.name from customer client;


select client.person.address.street from customer client;


select client.person.name, client.person.address.city from customer
client where client.person.address.city like 'M%';