Chapter 8: Object-Oriented Databases
Chapter 8: Object-Oriented Databases
$
• New Database Applications
• Object-Oriented Languages
&
Database Systems Concepts 8.1 Silberschatz, Korth and Sudarshan
1997
c
%
' New Database Applications
$
• Data models designed for data-processing-style applications
are not adequate for new technologies such as computer-aided
design, computer-aided software engineering, multimedia and
image databases, and document/hypertext databases.
• These new applications requirement the database system to
handle features such as:
– complex data types
– data encapsulation and abstract data structures
& %
– novel methods for indexing and querying
& %
Smalltalk, C++) to database systems.
& %
implementor of the object
• Messages and responses provide the only external interface to
an object.
& %
represented by a variable and two methods, e.g., the attribute
address is represented by a variable address and two
messages get-address and set-address.
– For convenience, many object-oriented data models permit
direct access to variables of other objects
& %
• Example: Group objects for people into a person class
• Classes are analogous to entity sets in the E-R model
& %
int employment-length();
};
& %
– variables/messages applicable to all persons associated
with class person.
– variables/messages specific to employees associated with
class employee; similarly for customer
person
employee customer
& %
officer teller secretary
& %
class officer isa employee {
int office-number ;
int expense-account-number ;
};
..
.
& %
1. Class extent of employee includes all officer, teller and
secretary objects
2. Class extent of employee includes only employee objects
that are not in a subclass such as officer, teller or secretary
person
employee customer
&
Database Systems Concepts 8.12 Silberschatz, Korth and Sudarshan
1997
c
%
' Multiple Inheritance
$
• The class/subclass relationship is represented by a directed
acyclic graph (DAG) — a class may have more than one
superclass.
• A class inherits variables and methods from all its
superclasses.
• There is potential for ambiguity. E.g., variable with the same
name inherited from two superclasses. Different solutions such
as flag and error, rename variables, or choose one.
• Can use multiple inheritance to model “roles” of an object.
– A person can play the roles of student, a teacher or
& %
footballPlayer, or any combination of the three (e.g., student
teaching assistants who also play football).
– Create subclasses such as student-teacher and
student-teacher-footballPlayer that inherit from multiple
classes.
& %
language.
∗ no user-supplied identifier is required.
∗ form of identity used in object-oriented systems.
&
Database Systems Concepts 8.15 Silberschatz, Korth and Sudarshan
1997
c
%
' Object Containment
$
bicycle
& %
• Multiple levels of containment create a containment hierarchy:
links interpreted as is-part-of, not is-a.
• Allows data to be viewed at different granularities by different
users
& %
object-orientation to relational language.
– Persistent programming languages – extend object-oriented
programming language to deal with databases by adding
concepts such as persistence and collections.
& %
make programming errors that damage the database.
• Complexity of languages makes automatic high-level
optimization more difficult.
• Do not support declarative querying very well.
& %
termination.
– Reference – declare (root) persistent objects; objects are
persistent if they are referred to (directly or indirectly) from a
root object.
& %
– Persistent – identity persists throughout program executions
and structural reorganizations of data; required for
object-oriented systems.
&
Database Systems Concepts 8.21 Silberschatz, Korth and Sudarshan
1997
c
%
' Storage and Access of Persistent Objects
$
How to find objects in the database:
& %
– All objects have object identifiers.
&
Database Systems Concepts 8.23 Silberschatz, Korth and Sudarshan
1997
c
%
' Persistent C++ Systems
$
• C++ language allows support for persistence to be added
without changing the language
– Declare a class called Persistent Object with attributes
and methods to support persistence
– Overloading – ability to redefine standard function names
and operators (i.e., +, −, the pointer dereference operator
->) when applied to new types
• Providing persistence without extending the C++ language is
& %
– relatively easy to implement
– but more difficult to use
& %
delete element.
• The C++ object definition language (ODL) extends the C++
type definition syntax in minor ways.
Example: Use notation inverse to specify referential integrity
constraints.
& %
Ref<Branch> home branch;
Set<Ref<Account>> accounts inverse Account::owners;
};
&
Database Systems Concepts 8.27 Silberschatz, Korth and Sudarshan
1997
c
%
' ODMG C++ Object Manipulation Language
$
• Uses persistent versions of C++ operators such as new(db).
& %
when they are created; called automatically when new is
executed
• Destructor for a class – a special method that is called when
objects in the class are deleted
& %
cust->accounts.insert element(account);
account->owners.insert element(cust);
... Code to initialize customer id, account number etc.
Trans.commit();
}
& %
}
Trans.commit();
}