Object Database System
Object Database System
SUSHIL KULKARNI
Object Database System :
Objectives
◆ Problems with RDBMS
◆ What is ODBMS and ORDBMS ?
◆ Advantages and Disadvantages
◆ OO/ER model comparison and object
schema
◆ Object type : Attributes and Methods
◆ Collection types
2
PROBLEMS
3
Problems
◆ Poor representation of ‘real world’ Entities.
◆ Example:
4
Problems !
treats
killed
doctor patient
d_no d_no
d_no p_no
p_no p pname
dname
_no
5
PROBLEMS !
◆ Homogeneous data structure
6
PROBLEMS !
Options are:
Object-oriented databases ?
Object-relational databases ?
7
Begin with Example!
9
Begin with Example!
10
Begin with Example!
salesArea, carAllowance)
Secretary (staffNo, fName, IName, position, sex, DOB, salary,
typingSpeed)
11
Begin with Example!
12
ORDBMS Approach
◆ The best solution of all above problems is in
15
Example
Let us insert the values:
INSERT INTO manager VALUES
(staff(100,’ajay’,’arora’,’production
manager’,’m’,’25-feb 1976’,15000 ),
2000,’12-dec-2002’);
16
Example
Similarly we create other tables as shown below:
18
OO AND ER MODEL
COMPARISION
OO DATA MODEL E- R MODEL
Type Entity definition
Object Entity
Class Entity set
Instance Variable Attributes
N/A Primary Key
OID N/A
Method N/A
19
ODBMS
Object Oriented OO Concepts
Features OO Data model
OOPL
21
ODBMS
◆ Integrating database capabilities with object
programming language capabilities, the result is an
object-oriented database management system or
ODBMS.
◆ An ODBMS makes database objects appear as
programming language objects in one or more existing
programming languages.
◆ Object database management systems extend the object
programming language with transparently persistent
data, concurrency control, data recovery, associative
queries, and other database capabilities.
22
ODBMS
Following is the one of the approach for designing an
object-oriented database:
◆ The user will create classes, objects, inheritance and
so on.
◆ Database system will store and manage these objects
and classes.
◆ Translation layer is required to map the objects
created 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
23
Advantages
◆ The object-oriented data model allows the 'real world' to be
modeled more closely.
25
ORDBMS
ORDBMS = ODBMS + RDBMS
= (O + R) * DB * MS.
26
ORDBMS
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 as
though 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.
27
Advantages
◆ The object type can be reuse and share in different application.
28
Disadvantages
◆ Complexity increases and associated costs.
29
OBJECT
30
Object
◆ Uniquely identifiable entity that contains both the
attributes that describe the state of a real-world
entity and the actions associated with it.
31
Object Attribute
( Instance Variables)
21
32
Object State
◆ Set of values that object’s attributes have at a
given time.
◆ Can vary, although its OID remains the same.
◆ To change the object’s state, change the values
of the object’s attributes.
33
Object : PERSON
Attribute Name State: Attribute Value
PAN E12345
Last name Dixit
Middle name Ajay
First name Suhas
DOB 12/5/1959
Home Tel no. 24145643
Cell no. 9967770658
Email [email protected]
EMPLOYEE
NAME s
ADDRESS s
Sameer A. Sathe
112, L.N.Street ..
DOB s
23-NOV-1970
SEX s
M
AGE i
30
36
Method Components
Method=sum
sum=0
37
Depiction of an Object
38
DATA TYPES
FOR
ATTRIBUTES
39
Data types for attributes
Two types of attributes: Simple & Abstract
21
40
Object : PERSON ( cont’d)
Let us consider few attributes for Person object:
Attribute Name Attribute Value
Address * Street Address, House Number, City, State
Pin
Dept * HR, Accounts
26
41
Abstract Data Type
◆ Toadd address information for a person , we have to
consider separate attributes: Street Address, House
Number, City , State and Pin using primitive data
types.
21
42
Operations on ADT
◆ DBMS allows to store and retrieve images using
CLOB and BLOB like an object of any other type
such as number.
44
Structured Type: Object Type
◆ Structured type are type constructor . For example the
structured type for object person is given below using oracle:
◆ Creating Object
Table created.
46
EMP Structure
47
Insert into EMP
48
Select statement on EMP
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)
49
METHODS
50
Modeling Object Behavior :
Methods
54
OBJECT SCHEMA: GRAPHICAL
REPRESENTATION
STATE OF EMPLOYEE OBJECT INSTANCE
55
OBJECT SCHEMA: GRAPHICAL
REPRESENTATION
56
OBJECT SCHEMA: GRAPHICAL
REPRESENTATION
57
OBJECT SCHEMA: GRAPHICAL REPRESENTATION
PIN 400018
Object Identity ≠ Object Equality
◆ 2 objects are identical if they have the same OID
(o1 == 02)
59
Object Identity - Implementation
62
Inheritance
63
Inheritance
◆ The definition of an object type determines whether
subtypes can be derived from that type.
◆ For example:
64
Inheritance
CREATE TYPE person_typ AS OBJECT (
pid NUMBER,
name VARCHAR2(30),
phone VARCHAR2(20))
NOT FINAL;
/
Type Created.
Type Created.
Inheritance
CREATE TYPE employee_typ UNDER person_typ (
emp_id NUMBER,
mgr VARCHAR2(30));
/
Type Created.
66
Inheritance
CREATE TABLE contacts (
contact person_typ,
contact_date DATE );
67
Inheritance
◆ Attributes in general can be accessed using the
dot notation. Attributes of a subtype of a row or
column's declared type can be accessed with the
TREAT function.
◆ For example:
68
Inheritance
SELECT TREAT(contact AS student_typ).major FROM
contacts;
TREAT(CONTACTASSTUDENT_TYP).MA
------------------------------
HISTORY
PHYSICS
69
Inheritance
TREAT(CONTACTASSTUDENT_TYP).MA
TREAT(CONTACTASPERSON_TYP).NAME
------------------------------ ------------------------------
Hemant Agashe
HISTORY Sameer Bhende
PHYSICS Uday Chitale
70
COLLECTION
TYPE
71
Database Design For ORDBMS
◆ Database designer can get an opportunity to use rich
variety of data types for ORDBMS.
72
Database Design For ORDBMS
If you need
73
Database Design For ORDBMS
If you need
74
The Nested Relational Data Model
◆ Not in 1NF
◆ Example:
dept = (dno, manager, employees, projects, locations)
employees = (ename, dependents)
projects = (pname, ploc)
locations = (dloc)
dependents = (dname, age)
75
The Nested Relational Data Model
76
ORDBMS Vs RDBMS
◆ Using ORDBMS:
CREATE TABLE emp
(empid number,
employee person);
◆ Using RDBMS:
CREATE TABLE EMP
( empid number,...)