Chapter - 01 - Oodb - CS
Chapter - 01 - Oodb - CS
This includes some kind of support for classes of objects and the
inheritance of class properties and methods by subclasses and their
objects.
The advantage of the ODBMS when writing applications using the OOP
approach is the removal of impedance mismatch; that is, the program manages
and works with objects instead of rows of data that must be combined into an
object.
Many RDBMS vendors have extended their offerings into the object-relational
database management system (ORDBMS).
Put simply, object-oriented databases (OODB) are databases that represent data in the
form of objects and classes.
That said, we can use the following formula to outline the OODBM: Object-Oriented
Programming + Relational Database Features = Object-Oriented Database Model
Relational database management systems (RDBMS) currently are the most widely-
deployed type of DBMS.
The relational abstraction of rows and columns accessed using Structured Query
Language (SQL) is well understood by most IT professionals.
In contrast, object database systems can be better-suited for storing and manipulating
complex data relationships.
It can be more difficult for applications to access data with many relationships stored
across multiple tables in an RDBMS than to access the data as an object in an ODBMS.
system.
Later, it was revised into ODMG 2.0, which included a common architecture
and definitions for an OODBMS, definitions for an object model, an object
definition language (ODL), and object query language (OQL).
Objects: An object is the most basic element of an object model and it consists
of two components:
2. Behavior (operations).
1. Identifier: Each object is assigned a unique system generated identifier (OID) that
identifies it within the database.
2. Name: Some objects are also assigned a unique name within a particular database that can
be used to refer to that object in the program.
3. Lifetime: The lifetime of an object specifies whether the object is persistent (that is a
database object) or transient (a programming language object).
4. Structure: The structure of an object specifies how the object is created using a certain
type constructor. Various type constructors used in the object model are atom , tuple (or
row), set , list , bag and array.
Literal: A literal is basically a constant value that does not have an object identifier.
Literal can be of three types, namely, atomic , collection and structured.
1. Atomic literals correspond to the values of basic data types of the object model
including long, short, and unsigned integers, floating point numbers, Boolean values,
character, string and enumeration type values.
2. Collection literals define a value that is a collection of objects or values such as set,
array, list, bag, etc., but the collection itself does not have an object identifier.
3. Structured literals correspond to the values that are constructed using the tuple type
constructor. It includes built-in structures like Date, Interval, Time and Timestamp.
Compiled by: Temesgen Tilahun 14
Concepts and terminologies related to object model
In order to create object types (or instances) for atomic objects, the class
keyword is used which specifies the properties (state) and operations (behavior)
The properties define the state of an object type and are described by
attributes and relationships.
Compiled by: Temesgen Tilahun 15
Concepts and terminologies related to object model
Interface: Unlike a class that specifies both the abstract state and abstract
behavior of an object type, an interface specifies only the abstract behavior of
an object type.
Note: An interface may also specify properties (along with the operations) of
an object type; however, these cannot be inherited from the interface.
Compiled by: Temesgen Tilahun 16
Concepts and terminologies related to object model
Another kind of inheritance relationship is EXTENDS Relationship, which requires both the
supertype and the subtype to be classes.
This type of inheritance is specified using the keyword extends, and it cannot be used for
implementing multiple inheritance.
Note that if a class is used as a subtype in multiple inheritance then it can inherit state and behavior
from at most one other class using extends in addition to inheriting from several interfaces via (:).
Extents: In ODMG object model, an extent can be declared for any object type
(defined using class declaration), and it contains all the persistent objects of
that class.
Object definition language, a part of ODMG 2.0 standard, has been designed to
represent the structure of an object-oriented database.
ODL serves the same purpose as DDL (part of SQL), and is used to support various
constructs specified in the ODMG object model.
The main purpose of ODL is to model object specifications (classes and interfaces) and
their characteristics.
Any class in the design process has three characteristics that are attributes,
relationships, and methods.
class <name>
{
<list of properties>
};
For example, consider the Online Book database and its objects BOOK,
AUTHOR, PUBLISHER and CUSTOMER .
Object Query Language (OQL) is a standard query language designed for the
ODMG object model.
It resembles SQL (used for relational databases) but it also supports object-
oriented concepts of the object model, such as object identity, inheritance,
relationship sets, operations, etc.
Each Query in OQL needs an entry point to the database for processing.
For example, the query to retrieve the titles of all textbooks can be
specified as:
SELECT b.Book_title
FROM books b
The query retrieves only the persistent objects that satisfy the condition
and the collection of these objects is referred to by b.
In order to access the related attributes and objects of the object under
collection, we can specify a path expression.
SELECT b.Book_title
FROM books b
WHERE b.purchasedby.Name = ‘Allen’;
Here, the query retrieves a collection of all the books that are purchased
by the customer Allen using the path expression b.purchasedby.Name
If Allen has purchased more than one copy of the same book the query
will result in a bag of strings.
With the use of DISTINCT clause the same query will return a set of
FROM books b
For example, the following query results in a list of books purchased by Allen
in the ascending order by Category and in the descending order by Price.
SELECT DISTINCT b.Book_title
FROM books b
WHERE b.purchasedby.Name = ‘Allen’
ORDER BY b.Category ASC , b.Price DESC;
The two kinds of object databases are similar in terms of their functionalities.
Both the databases support structured types, object identity and reference
types.
?
Compiled by: Temesgen Tilahun 35