Object-Based Databases
Object-Based Databases
Object-Based Databases
Extend the relational data model by including object orientation and constructs to deal
with added data types.
Allow attributes of tuples to have complex types, including non-atomic values such as
nested relations.
Preserve relational foundations, in particular the declarative access to data, while
extending modeling power.
Upward compatibility with existing relational languages.
Complex Data Types
Motivation:
Permit non-atomic domains (atomic indivisible)
Example of non-atomic domain: set of integers,or set of tuples
Allows more intuitive modeling for applications with complex data
Intuitive definition:
allow relations whenever we allow atomic (scalar) values — relations within
relations
Retains mathematical foundation of relational model
Violates first normal form.
Example of a Nested Relation
Example: library information system
Each book has
title,
a list (array) of authors,
Publisher, with subfields name and branch, and
a set of keywords
Non-1NF relation books
4NF Decomposition of Nested Relation
Multisets
multiset [‘computer’, ‘database’, ‘SQL’]
Another approach to creating nested relations is to use subqueries in the select clause,
starting from the 4NF relation books4
select title,
array (select author
from authors as A
where A.title = B.title
order by A.position) as author_array,
Publisher (pub-name, pub-branch) as publisher,
multiset (select keyword
from keywords as K
where K.title = B.title) as keyword_set
from books4 as B
Object-Identity and Reference Types
Define a type Department with a field name and a field head which is a reference to the
type Person, with table people as scope:
create type Department (
name varchar (20),
head ref (Person) scope people)
We can then create a table departments as follows
create table departments of Department
We can omit the declaration scope people from the type declaration and instead make an
addition to the create table statement:
create table departments of Department
(head with options scope people)
Referenced table must have an attribute that stores the identifier, called the self-referential
attribute
create table people of Person
ref is person_id system generated;
Initializing Reference-Typed Values
To create a tuple with a reference value, we can first create the tuple with a null
reference and then set the reference separately:
insert into departments
values (`CS’, null)
update departments
set head = (select p.person_id
from people as p
where name = `John’)
where name = `CS’
User Generated Identifiers
The type of the object-identifier must be specified as part of the type definition of the
referenced table, and
The table definition must specify that the reference is user generated
create type Person
(name varchar(20)
address varchar(20))
ref using varchar(20)
create table people of Person
ref is person_id user generated
When creating a tuple, we must provide a unique value for the identifier:
insert into people (person_id, name, address ) values
(‘01284567’, ‘John’, `23 Coyote Run’)
We can then use the identifier value when inserting a tuple into departments
Avoids need for a separate query to retrieve the identifier:
insert into departments
values(`CS’, `02184567’)
User Generated Identifiers (Cont.)
Relational systems
simple data types, powerful query languages, high protection.
Persistent-programming-language-based OODBs
complex data types, integration with programming language, high performance.
Object-relational systems
complex data types, powerful query languages, high protection.
Object-relational mapping systems
complex data types integrated with programming language, but built as a layer on top of a
relational database system
Note: Many real systems blur these boundaries
E.g. persistent programming language built as a wrapper on a relational database offers
first two benefits, but may have poor performance.
Figure 22.05
Figure 22.07