Chapter 1
Introduction to Object Oriented
Databases
Contents:
Background
Basic OO concepts
OO DB schema design
Main Features of OO Data model
Standards of OO model
Object Definition Language
Object Query Language
Advanced Database System – Ch-1: OO Database Slide 2
Background
Relational DBMSs support a small, fixed collection of
data types (e.g. integer, dates, string, etc.) which has
proven adequate for traditional application domains such
as administrative and business data processing. RDBMSs
support very high-level queries, query optimization,
transactions, backup and crash recovery, etc.
However, many other application domains need complex
kinds of data such as CAD/CAM, multimedia repositories,
and document management.
Object-oriented strongly influenced efforts to enhance
database support for complex data and led to the
development of object-database systems.
Advanced Database System – Ch-1: OO Database Slide 3
Layers of Database Design
Relational Normalization & SQL
ER diagram RDBMS
database design Physical design table definitions
Mapping onto
Relations
(no operations)
UML class Mapping onto
Object-Relational Normalization & Extended-SQL
Relations and Object
Physical design table definitions ORDBMS
diagram types database design
Mapping directly
onto ODL classes
Object-Oriented
database schema Optimization OODBMS
in ODL
Advanced Database System – Ch-1: OO Database Slide 4
RELATIONAL MODEL
Relations are the key concept, everything
else is around relations
Primitive data types, e.g., strings, integer,
date, etc.
Great normalization, query optimization, and
theory
What is missing??
Handling of complex objects
Handling of complex data types
Code is not coupled with data
No inheritance, encapsulation, etc.
Advanced Database System – Ch-1: OO Database Slide 5
Object-database systems paths:
A database system that incorporates all the important
object-oriented concepts
Object-database systems have developed along two
distinct paths:
(1)Object-Oriented Database Systems. The approach is
heavily influenced by OO programming languages and can be
understood as an attempt to add DBMS functionality to a
programming language environment.
The Object Database Management Group (ODMG) has
developed a standard Object Data Model (ODM) and Object
Query Language (OQL), which are the equivalent of the SQL
standard for relational database systems.
Advanced Database System – Ch-1: OO Database Slide 6
Object-database systems paths:
(2) Object-Relational Database Systems. ORDB
systems can be thought of as an attempt to extend
relational database systems with the functionality
necessary to support a broader class of application
domains, provide a bridge between the relational and
object-oriented paradigms. This approach attempts to
get the best of both.
The SQL:1999 (also known as SQL3) standard extends SQL to
incorporate support for ORDB systems
RDDMS vendors, such as IBM, Informix, ORACLE have added
ORDBMS functionality to their products.
Advanced Database System – Ch-1: OO Database Slide 7
Basic OO concepts
A conceptual entity is anything that exists and can
be distinctly identified.
E.g. a person, an employee, a car, a part
In an OO system, all conceptual entities are
modeled as objects.
An object has structural properties defined by a
finite set of attributes and behavioural properties
defined by a finite set of methods.
Advanced Database System – Ch-1: OO Database Slide 8
Basic OO concepts …
Each object is associated with a logical non-reusable
and unique object identifier (OID). The OID of an
object is independent of the values of its attributes.
All objects with the same set of attributes and
methods are grouped into a class, and form instances
of that class.
Classes are classified as lexical classes and non-lexical
classes.
Advanced Database System – Ch-1: OO Database Slide 9
Basic OO concepts …
A lexical class contains objects that can be directly
represented by their values.
E.g. integer, string.
A non-lexical class contains objects, each of which is
represented by a set of attributes and methods.
Instances of a non-lexical class are referred to by their
OIDs.
E.g. PERSON, EMPLOYEE, PART are non-lexical
classes.
Advanced Database System – Ch-1: OO Database Slide 10
OO Schema Design
Entity-Relationship Diagrams can be extended to
support OO schema design.
All the structural properties of the OO approach can be
expressed in or derived from an ER diagram.
E.g. subclass-superclass relationship: ISA, UNION
composite object: IS-PART-OF existentially dependent
object: EX and ID dependent relationships
Methods and derived attributes can be defined for both
entity types and relationship types
Advanced Database System – Ch-1: OO Database Slide 11
OO Schema Design …
An ER diagram augmented with methods is called
an OOER diagram.
An OOER diagram is a normal form OOER
diagram if its corresponding ER diagram is a NF-
ER diagram, and there are no inheritance conflicts
in its ISA hierarchies.
Advanced Database System – Ch-1: OO Database Slide 12
OOER Diagram
Advanced Database System – Ch-1: OO Database Slide 13
Class Diagram
UML class diagram also allows you to
model OO schema
generali
tion
Advanced Database System – Ch-1: OO Database Slide 14
OBJECT-ORIENTED MODEL
Features
Relations are not the central concept, classes
and objects are the main concept
Object-Oriented DBMS(OODBMS) are DBMS based
on an Object- Oriented Data Model inspired by OO
programming languages
Main Features:
• Powerful type system
• Classes
• Object Identity
• Inheritance
OODBMS are capable of storing complex objects,
i.e., objects that are composed of other objects,
and/or multi-valued attributes.
Advanced Database System – Ch-1: OO Database Slide 15
FEATURE 1: POWERFUL TYPE SYSTEM
Primitive types
• Integer, string, date, Boolean, float, etc.
Structure type
• Attribute can be a record with a schema
• E.g Struct {integer x, string y}
Collection type
• Attribute can be a Set, Bag, List, Array of
other types
Reference type
• Attribute can be a Pointer to another object
Advanced Database System – Ch-1: OO Database Slide 16
FEATURE 2: CLASSES
• A ‘class’ is in replacement of ‘relation’
• Same concept as in OO programming languages
• All objects belonging to a same class share
the same properties and behaviour
• An ‘object’ can be thought of as ‘tuple’ (but
richer content)
• Classes encapsulate data + methods +
relationships, unlike relations that contain
data only
• In OODBMSs objects are persistency (unlike
OO programming languages)
Advanced Database System – Ch-1: OO Database Slide 17
FEATURE 3: OBJECT IDENTITY
OID is a unique identity of each object regardless of
its content
Even if all attributes are the same, still objects have
different OIDs
Easier for references
An object is made of two things:
State: attributes (name, address, birthDate of a person)
Behaviour: operations (age of a person is computed from
birthDate and current date)
Advanced Database System – Ch-1: OO Database Slide 18
FEATURE 4: INHERITANCE
Person
A class can be defined in terms of
another one. name: {firstName: string,
middleName: string,
lastName: string}
address: string
birthDate: date
Person is super-class and Student age(): Integer
is sub-class. changeAddress(newAdd: string)
Student class inherits attributes Student
and operations of Person. regNum: string {PK}
major: string
register(C: Course): boolean
Advanced Database System – Ch-1: OO Database Slide 19
STANDARDS FOR OBJECT-ORIENTED
MODEL
• ODMG: Object Data Management Group (1991)
• provide a standard where previously there was
none
• support portability between
products
• standardize model, querying and programming
issues
• Language of specifying the structure of object
database
• ODL: Object Definition Language
• OQL: Object Query Language
• ODL is somehow similar to DDL (Data Definition
Language) in SQL
Advanced Database System – Ch-1: OO Database Slide 20
ODL: CLASSES & ATTRIBUTES
Keyword attribute
Two classes with their attributes
Attribute as a structure
Advanced Database System – Ch-1: OO Database Slide 21
ODL: RELATIONSHIPS
Keyword relationship
Keyword set
Set: set of unsorted unique
objects
Bag: set of unsorted objects
with possible duplication
List: set of sorted list
Array: set of sorted list
referenced by index
Advanced Database System – Ch-1: OO Database Slide 22
ODL: METHODS
Three methods declarations
Parameters are either
IN, OUT, or INOUT
Definition (implementation) is
not part of the class
Advanced Database System – Ch-1: OO Database Slide 23
ODL: INHERITANCE
• Same Idea as in OO programming (C++ or Java)
• Subclass inherits all attributes, relationships, and methods
• Plus adding additional fields
Keyword extends
Cartoon movie is a movie
with voices of characters
Murder movie is a movie
with the weapons used
Inherits from two other
classes
Advanced Database System – Ch-1: OO Database Slide 24
ODL: INSTANCES & KEYS
• Instance of a class are all objects currently exist of that class
• In ODL that is called extent (and is given a name)
• Keys are not as important for referencing objects
• Because each object already has a unique OID
• Defining keys in ODL is optional
• ODL allows defining multiple keys (Comma separated)
Keywords extent & key
The key is the pair of (title, year)
The key is the pair of (empID, SSN)
Two keys empID and SSN
Advanced Database System – Ch-1: OO Database Slide 25
OQL: OBJECT-ORIENTED QUERY
LANGUAGE
• OQL is a query language designed to operate
on
databases described in ODL.
• Tries to bring some concepts from the relational model
to
the• E.g.,
ODBMs the SELECT statement, joins, aggregation, etc.
• Reference of class properties (attributes, relationships,
and methods) using:
• Dot notation (p.a), or
• Arrow notation (p->a)
• In OQL both notations are equivalent
Advanced Database System – Ch-1: OO Database Slide 26
OQL: EXAMPLE QUERIES I
Reference the extent (instance of class)
Select the year of movie ‘Gone with the wind’
For each movie m, s is the set of stars in
that movie (follow a relationship)
Select star names from movie ‘Casablanca’
Another notation
Advanced Database System – Ch-1: OO Database Slide 27
OQL: EXAMPLE QUERIES II
Select distinct star names in movies owned by ‘Disney’
subquery
order movies owned by ‘Disney’ based on length and title
Report set of structures
Join two classes
Report pairs of stats who have the same address
Advanced Database System – Ch-1: OO Database Slide 28
OQL OUTPUT
• Unlike SQL which produces relations, OQL produces
collection (set, bag, list) of objects
• The object can be of any
type
Set of strings
Set of objects of type Movie
Set of structures
Advanced Database System – Ch-1: OO Database Slide 29