Object Database system
-
Upload
sushil-kulkarni -
Category
Documents
-
view
227 -
download
0
Transcript of Object Database system
-
8/14/2019 Object Database system
1/78
SUSHIL KULKARNI
OBJECT DATABASE SYSTEM
-
8/14/2019 Object Database system
2/78
2
Object Database System :
Objectives
x Problems with RDBMS
x What is ODBMS and ORDBMS ?
x Advantages and Disadvantages
x OO/ER model comparison and object
schema
x Object type : Attributes and Methods
x Collection types
-
8/14/2019 Object Database system
3/78
3
PROBLEMS
-
8/14/2019 Object Database system
4/78
4
ProblemsProblems
x Poor representation of real world Entities.
- Relations are too dry, contains only state of a
relation.
- Relationships are not known.
x Example:
-
8/14/2019 Object Database system
5/78
5
Problems !Problems !
killed
d_no
dok
p_no
treats
d_no
since
p_no
doctor
d_no
telno city
dname
paddress
patient
p
_no
pname
-
8/14/2019 Object Database system
6/78
6
PROBLEMS !PROBLEMS !
x Homogeneous data structure
All rows have the same number of attributes.
All values in a column are of the same type. All attribute values are atomic.
x
Fixed length of data type, Limited data types Can not store images, audio and video clips.
Spatial, temporal data can not be added.
-
8/14/2019 Object Database system
7/78
7
PROBLEMS !PROBLEMS !
x Reusability (inheritance) of a table is not possible.
Options are:Object-oriented databases ?
Object-relational databases ?
-
8/14/2019 Object Database system
8/78
8
Storing Objects in a Relational Database
For the purposes of discussion, consider the inheritance
hierarchy which has a super class:
Staff
and three subclasses:
Manager,
SalesPersonnel,
Secretary.
Begin with ExampleBegin with Example!!
-
8/14/2019 Object Database system
9/78
9
Begin with ExampleBegin with Example!!
-
8/14/2019 Object Database system
10/78
10
Map each class to a relation:
Staff(staffNo, fName, IName, position, sex, DOB, salary)
Begin with ExampleBegin with Example!!
-
8/14/2019 Object Database system
11/78
11
Map each subclass to a class and convert to relation
Manager (staffNo, fName, IName, position, sex, DOB, salary,
bonus, mgrStartDate)
SalesPersonnel (staffNo, fName, IName, position, sex, DOB, salary,
salesArea, carAllowance)
Secretary (staffNo, fName, IName, position, sex, DOB, salary,
typingSpeed)
Begin with ExampleBegin with Example!!
-
8/14/2019 Object Database system
12/78
12
Map the hierarchy to a single relation
Staff(staffNo, fName, IName, position, sex, DOB, salary, bonus,
mgrStartDate, sales-Area, carAllowance, typingSpeed, typeFlag)
Begin with ExampleBegin with Example!!
-
8/14/2019 Object Database system
13/78
13
x The best solution of all above problems is in
Object Relational Database Management System.
x For example: In Oracle ,we can create an object Staffin database and then we can create three differenttables namely Manager, Salepersonnel and Secretary,
each refer to object created Staff as one of itsattribute.
x The whole process of designing the above databasewith syntax of Oracle 9i is explained here below:
ORDBMS ApproachORDBMS Approach
-
8/14/2019 Object Database system
14/78
14
Creation of an object staff:
CREATE TYPE staff AS OBJECT(
staffno number(4) primary key,fname varchar(20),
lname varchar(20),
position varchar(10),
sex varchar(1),
DOB date,
salary number(8,2));
ExampleExample
-
8/14/2019 Object Database system
15/78
15
The object staff can be referenced in table Manager as one
of its attribute as shown below:
CREATE TABLE manager(staff_detail staff,
bonus number(5),
mgrstartdate date);
ExampleExample
-
8/14/2019 Object Database system
16/78
16
Let us insert the values:
INSERT INTO manager VALUES
(staff(100,ajay,arora,production
manager,m,25-feb 1976,15000 ),
2000,12-dec-2002);
ExampleExample
-
8/14/2019 Object Database system
17/78
17
Similarly we create other tables as shown below:
CREATE TABLE salepersonnel(
staff_detail staff,salearea varchar(25),
carallowance number(7));
CREATE TABLE secretary(
staff_detail staff,
typingspeed number(3));
ExampleExample
-
8/14/2019 Object Database system
18/78
18
In response to the increasing complexity of
database applications, two 'new' data models have
emerged:
Object-Oriented Data Model (OODM)
Object-Relational Data Model (ORDM)
New data ModelsNew data Models
-
8/14/2019 Object Database system
19/78
19
OO AND ER MODELOO AND ER MODEL
COMPARISIONCOMPARISION
N / AMethod
N / AOID
Primary KeyN / A
AttributesInstance Variable
Entity setClassEntityObject
Entity definitionType
E- R MODELE- R MODELOO DATA MODELOO DATA MODEL
-
8/14/2019 Object Database system
20/78
20
OODBMSDBMS
ODBMSODBMS
Object Oriented
Features
Conventional DBMSConventional DBMS
FeaturesFeatures
++
OO Concepts
OO Data model
OOPL
Data accessibility
Persistence
Back up & recovery
Transaction
Concurrency
Security
-
8/14/2019 Object Database system
21/78
21
OODBMSDBMS
ODBMS is the MS process methods applied forDB data structure, which is complied with O
objects.
ODBMS = O * DB * MS
-
8/14/2019 Object Database system
22/78
22
x Integrating database capabilities with objectprogramming language capabilities, the result is anobject-oriented database management system orODBMS.
x An ODBMS makes database objects appear asprogramming language objects in one or more existingprogramming languages.
x Object database management systems extend the objectprogramming language with transparently persistentdata, concurrency control, data recovery, associativequeries, and other database capabilities.
ODBMSODBMS
-
8/14/2019 Object Database system
23/78
23
Following is the one of the approach for designing an
object-oriented database:
x The user will create classes, objects, inheritance and
so on.x Database system will store and manage these objects
and classes.
x
Translation layer is required to map the objectscreated by user into objects of the database system.
Object Database (ODBMS) for Java, written entirely in Java, and
compliant with the Java Data Objects (JDO) standard developed
ODBMSODBMS
-
8/14/2019 Object Database system
24/78
24
x The object-oriented data model allows the 'real world' to bemodeled more closely.
x ODBMSs allow new data types to be built from existing types.
x More expressive query language then SQL.
x Applicability to advanced database applications
There are many areas where traditional DBMSs have not been
particularly successful, such as, Computer-Aided Design (CAD),
CASE, Office Information Systems (OIS), and Multimedia
Systems. The enriched modeling capabilities of OODBMSs have
made them suitable for these applications.
AdvantagesAdvantages
-
8/14/2019 Object Database system
25/78
25
x No universally agreed data model for an ODBMS, andmost models lack a theoretical foundation.
x In comparison to RDBMSs, the use of ODBMS is stillrelatively limited.
xThere is no standard object-oriented query language.`
x
Lack of support for views.xNo adequate security mechanisms for accessing objects.
DisadvantagesDisadvantages
-
8/14/2019 Object Database system
26/78
26
ORORDBMSDBMS
ORDBMS is the MS process methods applied for DB
data structure, which is complied with O object and R
Relational concepts.
ORDBMS = ODBMS + RDBMSORDBMS = ODBMS + RDBMS
= (O + R) * DB * MS.= (O + R) * DB * MS.
-
8/14/2019 Object Database system
27/78
27
This system simply puts an object oriented front end on a
relational database (RDBMS). When applications interface
to this type of database, it will normally interface asthough the data is stored as objects.
The system will convert the object information into data
tables with rows and columns and handle the data the
same as a relational database.
ORDBMSORDBMS
-
8/14/2019 Object Database system
28/78
28
x The object type can be reuse and share in different application.
x
ORDBMS provides increased productivity both for thedeveloper and for the end user.
x It is just an extension of existing relational approach.
AdvantagesAdvantages
-
8/14/2019 Object Database system
29/78
29
x Complexity increases and associated costs.
x Simplicity and purity of the relational model are lost.
x Because the ORDBMS converts data between an object orientedformat and RDBMS format, speed performance of the databaseis degraded substantially. This is due to the additional conversionwork the database must do.
DisadvantagesDisadvantages
-
8/14/2019 Object Database system
30/78
30
OBJECT
-
8/14/2019 Object Database system
31/78
31
ObjectObject
x Uniquely identifiable entity that contains both the
attributes that describe the state of a real-world
entity and the actions associated with it.
Definition is similar to definition of an entity,
however, object encapsulates both state and
behavior; an entity only models state.
Object Attribute
-
8/14/2019 Object Database system
32/78
3221
Object Attribute
( Instance Variables)
Attributes - contains current state of an object.
- Known as instance variables in OO environment.
-
8/14/2019 Object Database system
33/78
33
Object State
x Set of values that objects attributes have at a
given time.
x Can vary, although its OID remains the same.
x To change the objects state, change the values
of the objects attributes.
-
8/14/2019 Object Database system
34/78
3426
Object : PERSON
State: Attribute ValueAttribute Name
9967770658Cell no.
24145643Home Tel no.
12/5/1959DOB
SuhasFirst name
AjayMiddle name
DixitLast name
E12345PAN
These are the simple or primitive attributes
-
8/14/2019 Object Database system
35/78
35
OBJECT SCHEMA: GRAPHICALOBJECT SCHEMA: GRAPHICAL
REPRESENTATIONREPRESENTATION
NAME s
ADDRESS s
DOB s
SEX sAGE i
EMPLOYEE
Sameer A. Sathe
112, L.N.Street ..
23-NOV-1970
M30
SHARED REPRESENTATION FOR ALL OBJECTS OF THE
CLASS EMPLOYEE
INSTANCE VARIABLES OBJECT INSTANCES
-
8/14/2019 Object Database system
36/78
36
Methods
x Code that performs a specific operation on objects
data.
x Used to change the objects attribute values or to
return the value of selected object attributes.
x Represent real-world actions.
-
8/14/2019 Object Database system
37/78
-
8/14/2019 Object Database system
38/78
38
Depiction of an Object
-
8/14/2019 Object Database system
39/78
39
DATA TYPES
FORATTRIBUTES
-
8/14/2019 Object Database system
40/78
4021
Data types for attributes
Two types of attributes: Simple & Abstract
x
Simple attribute are conventional attributes likenumber, string ,which takes on literal values.
x They are also called primitive attributes.
-
8/14/2019 Object Database system
41/78
4126
Object : PERSON ( contd)
Attribute ValueAttribute Name
HR, AccountsDept *
Street Address, House Number, City, State
Pin
Address *
*Represents an attribute represent one or more attributes.
Let us consider few attributes for Person object:Let us consider few attributes for Person object:
-
8/14/2019 Object Database system
42/78
4221
Abstract Data Type
xTo add address information for a person , we have to
consider separate attributes: Street Address, House
Number, City , State and Pin using primitive data
types.
xWith abstract data typing, we can create a new data
type and manipulate the data as if it were primitive
data type.
-
8/14/2019 Object Database system
43/78
4321
Operations on ADT
xDBMS allows to store and retrieve images using
CLOB and BLOB like an object of any other type
such as number.
xOne can define operations on an image data type such
as compress, rotate, shrink and crop.
xADT is the combination of an atomic data type and
its associated methods.
-
8/14/2019 Object Database system
44/78
44
STRUCTURED TYPE
USING ORACLE
-
8/14/2019 Object Database system
45/78
-
8/14/2019 Object Database system
46/78
46
Create EMP Table
x Creating Table with ADT Object Datatype
Now we will create EMP table for employees.
CREATE TABLE EMP( EMPID Number primary key,
EMPLOYEE PERSON);
Table created.
-
8/14/2019 Object Database system
47/78
47
EMP Structure
xUse DESC command to see the table structure.
SQL> DESC EMPName Null? Type
----------------------- -------- ------------
EMPID NOT NULL NUMBER
EMPLOYEE PERSON
-
8/14/2019 Object Database system
48/78
48
Insert into EMP
x We will now populate our table.
SQL> INSERT INTO EMP(empid, employee)
VALUES(1001,
person(122,'Sushil','Trymbak','Kulkarni',
'29-jun- 1984','24144386',10000));1 row created.
SQL> INSERT INTO EMP1 (empid, employee)
VALUES(1002,
person(124,'Suhas','Ramchandra','Dixit',
'13-may-1988','24124886',120000));1 row created.
-
8/14/2019 Object Database system
49/78
49
Select statement on EMP
We can select the records with simple SQL statement. E.g.
SELECT *
FROM EMP
/
EMPID
----------EMPLOYEE(PIN, FIRST_NAME, MIDDLE_NAME, LAST_NAME, DOB,
TEL_NO, SALARY)
-------------------------------------------------------
1001
person(122,'Sushil','Trymbak','Kulkarni','29-jun- 1984','24144386',10000)
1002
person(124,'Suhas','Ramchandra','Dixit',
'13-may-1988','24124886',120000)
-
8/14/2019 Object Database system
50/78
-
8/14/2019 Object Database system
51/78
-
8/14/2019 Object Database system
52/78
-
8/14/2019 Object Database system
53/78
-
8/14/2019 Object Database system
54/78
54
Object IdentityObject Identity
x Object identifier (OID) assigned to object when it is
created that is:
System-generated.
Unique to that object.
Invariant.
Independent of the values of its attributes (that is,
its state). Invisible to the user.
-
8/14/2019 Object Database system
55/78
OBJECT SCHEMA: GRAPHICALOBJECT SCHEMA: GRAPHICAL
-
8/14/2019 Object Database system
56/78
56
OBJECT SCHEMA: GRAPHICALOBJECT SCHEMA: GRAPHICAL
REPRESENTATIONREPRESENTATION
F_NAME s
M_NAME s
L_NAME s
NAME
DEFINING THREE ABSTRACT DATA TYPE
BLDG.NO i
STREET s
CITY s
STATE s
PIN i
ADDRESS
DAY i
MONTH i
YEAR i
DOB
OBJECT SCHEMA: GRAPHICALOBJECT SCHEMA: GRAPHICAL
-
8/14/2019 Object Database system
57/78
57
OBJECT SCHEMA: GRAPHICALOBJECT SCHEMA: GRAPHICAL
REPRESENTATIONREPRESENTATION
NAME
ADDRESS
DOB
SEXAGE
EMPLOYEE
OBJECT REPRESENTATION FOR INSTANCES OF THE
CLASS EMPLOYEE WITH ADTS
NAME
ADDRESS
DOB
SEXAGE
Data Types
-
8/14/2019 Object Database system
58/78
58
F_NAME Sameer
M_NAME A.
L_NAME Sathe
NAME OID X 201
BLDG.NO 112
STREET N.L.Street
CITY Mumbai
STATE MAHA.
PIN 400018
ADDRESS OID X 202
DAY 23
MONTH 11
YEAR 1970
DOB OID X 203
NAME X 201
ADDRESS X 202
DOB X 203SEX M
AGE 30
EMPLOYEE OID X 20
OBJECT SCHEMA: GRAPHICAL REPRESENTATIONOBJECT SCHEMA: GRAPHICAL REPRESENTATION
-
8/14/2019 Object Database system
59/78
59
Object Identity Object Equalityx 2 objects are identical if they have the same OID
(o1 == 02)
x 2 objects are equal if they have the same value
(o1 = 02)
(o1 == 02) (o1 = 02)(o1 = 02) (o1 == 02)NON !
-
8/14/2019 Object Database system
60/78
-
8/14/2019 Object Database system
61/78
6125
Advantages of OIDs
x They are efficient.
x They are fast.
x They cannot be modified by the user.
x They are independent of content.
Value + OID = object
-
8/14/2019 Object Database system
62/78
62
INHERITANCE
I h i
-
8/14/2019 Object Database system
63/78
63
Inheritance
-
8/14/2019 Object Database system
64/78
-
8/14/2019 Object Database system
65/78
-
8/14/2019 Object Database system
66/78
I h it
-
8/14/2019 Object Database system
67/78
67
Inheritance
CREATE TABLE contacts (contact person_typ,
contact_date DATE );
INSERT INTO contacts
VALUES (person_typ (12, 'Hemant Agashe', '99765432414'),
'24 Jun 2003' );
1 row created.
INSERT INTO contacts
VALUES (student_typ(51, 'Sameer Bhende', '9967452317', 12,
'HISTORY'),'24 Jun 2003' );
1 row created.
INSERT INTO contacts
VALUES (part_time_student_typ(52, 'Uday Chitale',
'9978561234', 14,'PHYSICS', 20), '24 Jun 2003' );
1 row created.
-
8/14/2019 Object Database system
68/78
-
8/14/2019 Object Database system
69/78
69
Inheritance
SELECT TREAT(contact AS student_typ).major FROMcontacts;
TREAT(CONTACTASSTUDENT_TYP).MA
------------------------------
HISTORY
PHYSICS
-
8/14/2019 Object Database system
70/78
70
Inheritance
SQL> SELECT TREAT(contact AS student_typ).major ,TREAT(contact AS person_typ).name FROM contacts;
TREAT(CONTACTASSTUDENT_TYP).MATREAT(CONTACTASPERSON_TYP).NAME
------------------------------ ------------------------------
Hemant Agashe
HISTORY Sameer Bhende
PHYSICS Uday Chitale
-
8/14/2019 Object Database system
71/78
-
8/14/2019 Object Database system
72/78
72
Database Design For ORDBMS
x Database designer can get an opportunity to use richvariety of data types for ORDBMS.
x Creating Collection Data types:
A varray is an ordered collection of elements.
A nestedtable can have any number of elements.
-
8/14/2019 Object Database system
73/78
-
8/14/2019 Object Database system
74/78
-
8/14/2019 Object Database system
75/78
75
The Nested Relational Data Model
x Not in 1NF
x Example:
dept = (dno, manager, employees, projects, locations)
employees = (ename, dependents)
projects = (pname, ploc)
locations = (dloc)
dependents = (dname, age)
-
8/14/2019 Object Database system
76/78
-
8/14/2019 Object Database system
77/78
-
8/14/2019 Object Database system
78/78
Email: sushiltry@yahoo co in Mob: 9967770658
mailto:[email protected]:[email protected]