Object Oriented Database Management
Object Oriented Database Management
Object Oriented Database Management
Motivation of ODBMSs
Application
data structures
Copy and
Transparent
translation
Relational ODBMS
representation data transfer
RDBMS
C compiler
SQL library calls + C
SQL+ C
pre-
compiler
.o file
loader
SQL library
object
code
int del;
try { del = cmd.ExecuteNonQuery();
MessageBox.Show(del+" Records Deleted Successfully!!!");
} catch { MessageBox.Show("Cannot Delete Any record!!!"); }
} } }
/* SQL embedded in C# to delete record of teacher where “tid” is equal to the user input*/
Object Oriented Database Management
• Object:
– observable entity in the world being modeled
– similar to concept to entity in the E/R model
• An object consists of:
– attributes: properties built in from primitive types
– relationships: properties whose type is a reference to some other object
or a collection of references
– methods: functions that may be applied to the object.
Class
person
employee student
RA TA
Multiple Inheritance
bicycle
• Persistent objects are stored in the database and accessed from the
programming language.
• Classes declared in ODL mapped to the programming language type
system (ODL binding).
• Low protection
– since persistent objects manipulated from applications directly, more
changes that errors in applications can violate data integrity.
• Non-declarative interface:
– difficult to optimize queries
– difficult to express queries
• But …..
– Most ODBMSs offer a declarative query language OQL to overcome the
problem.
– OQL is very similar to SQL and can be optimized effectively.
– OQL can be invoked from inside ODBMS programming language.
– Objects can be manipulated both within OQL and programming language
without explicitly transferring values between the two languages.
– OQL embedding maintains simplicity of ODBMS programming language
interface and yet provides declarative access.
OQL Example
Interface Projects{
interface Employee {
attribute string name;
attribute string name; relationship setof(Employee) team
relationship inverse Emplolyee works-for;
setof(Projects) works-for int number-of-employees();
inverse Projects::team; }
}
Select number-of-employees()
From Employee e, e.works-for
where name = “sharad”
CMSC-461
Database Management Systems
OQL -- Motivation
• For every class we can declare an extent = name for the current
set of objects of the class.
– Remember to refer to the extent, not the class name, in queries.
Example
• interface Bar
(extent Bars)
{
attribute string name;
attribute string addr;
relationship Set<Sell> beersSold
inverse Sell::bar;
}
Path Expressions
• The five operators avg, min, max, sum, count apply to any
collection, as long as the operators make sense for the element
type.
Example