Advanced Database Management
Faculty Name : Dr. Dipti Jadhav
Lecture 1
Chapter 3: Object Relational
and Extended Relational
Databases
HISTORY OF DATABASES
file systems (1950s) store data after process created it
has ceased to exists
hierarchical/ network (1960s) •concurrency
• recovery
• fast access
• complex structures
relational (1970-80s) •more reliability
• less redundancy
• more flexibility
• multiple views
•ODBMS (1990s) better simulation
more (and complex) data types more
relationships (e.g. aggregation,
specialisation)
single language for database AND
programming
better versioning
no 'reconstruction' of objects
other OO advantages (reuse,
inheritance etc.)
Introduction to Testing
STONEBRAKER’S APPLICATION MATRI
Most applications will move to the upper right
Introduction to Testing
MOTIVATION
Relational model (70’s):
Clean and simple.
Great for administrative and transactional data.
Not as good for other kinds of complex data (e.g., multimedia, networks, CAD).
Object-Oriented models (80’s):
Complicated, but some influential ideas from Object Oriented
Complex data types.
Idea: Build DBMS based on OO model.
Programming languages have evolved from Procedural to Object Oriented. So why
not DBMSs ???
Introduction to Testing
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 inherence, encapsulation, etc.
Introduction to Testing
RELATIONAL MODEL OF A ‘CAT’
Introduction to Testing
OBJECT ORIENTED MODEL OF A ‘CAT’
• Object-oriented database of a cat:
Introduction to Testing
The first areas where ODBMS were widely used were:
CASE
CAD
CAM
Increasingly now used in:
telecommunications
healthcare
finance
multimedia
text/document/quality management
Introduction to Testing
TWO APPROACHES
Object-Oriented Model (OODBMS)
• Pure OO concepts
Object-Relational Model (ORDBMS)
• Extended relational model with OO concepts
Introduction to Testing
DATABASE DESIGN PROCESS
Introduction to Testing
LOGICAL & PHYSICAL LAYERS
Introduction to Testing
EXAMPLE OF UML CLASSES
Introduction to Testing
FIRST APPROACH: OBJECT-ORIENTED MODEL
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.
Introduction to Testing
FEATURE 1: POWERFUL TYPE SYSTEM
Primitive types
Integer, string, date, Boolean, float, etc.
Structure type
Attribute can be a record with a schema
Collection type
Attribute can be a Set, Bag, List, Array of other types
Reference type
Attribute can be a Pointer to another object
Introduction to Testing
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 behavior
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)
Introduction to Testing
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)
Behavior: operations (age of a person is computed from birthDate and current date)
Introduction to Testing
FEATURE 4: INHERITANCE
A class can be defined in terms of another one.
Person is super-class and Student is sub-class.
Student class inherits attributes and operations of Person.
Introduction to Testing
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
Introduction to Testing
Overview of ODL & OQL
ODL: CLASSES & ATTRIBUTES
Introduction to Testing
ODL: RELATIONSHIPS
Introduction to Testing
ODL: RELATIONSHIPS & INVERSE RELATIONSHIPS
Introduction to Testing
ODL: MULTIPLICITY OF RELATIONSHIPS
Introduction to Testing
ODL: METHODS
Introduction to Testing
ODL: INHERITANCE
Introduction to Testing
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)
Introduction to Testing
WHAT’S NEXT
First Approach: Object-Oriented Model
• Concepts from OO programming languages
• ODL: Object Definition Language
• What about querying OO databases???
OQL: Object Oriented Query Language
Introduction to Testing
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 ODBMs
E.g., 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
Introduction to Testing
OQL: EXAMPLE QUERIES I
Introduction to Testing
OQL: EXAMPLE QUERIES II
Introduction to Testing
OQL OUTPUT
Unlike SQL which produces relations, OQL produces collection (set, bag, list) of objects
The object can be of any type
Introduction to Testing
OQL: AGGREGATION
Introduction to Testing
OQL: COLLECTION OPERATORS
Introduction to Testing
INTEGRATING OQL & EXTERNAL LANGUAGES
OQL fits naturally in OO host languages
Returned objects are assigned in variables in the host program
Introduction to Testing
WHAT’S NEXT
First Approach: Object-Oriented Model:
Concepts from OO programming languages
ODL: Object Definition Language
What about querying OO databases???
OQL: Object Oriented Query Language
Second Approach: Object-Relational Model
Introduction to Testing
SECOND APPROACH: OBJECTRELATIONAL MODEL
Object-oriented model tries to bring the main concepts from relational model to the OO
domain
The heart is OO concepts with some extensions.
Object-relational model tries to bring the main concepts from the OO domain to the
relational model
The heart is the relational model with some extensions
Extensions through user-defined types
Introduction to Testing
CONCEPTUAL VIEW OF OBJECTRELATIONAL MODEL
Relation is still the fundamental structure .
Relational model extended with the following features
Type system with primitive and structure types (UDT)
• Including set, bag, array, list collection types
• Including structures like records
Methods
Special operations can be defined over the user-defined types (UDT)
Specialized operators for complex types, e.g., images, multimedia, etc
Identifiers for tuples
Unique identifiers even for identical tuples.
References
Several ways for references and de-references
Introduction to Testing
CONCEPTUAL VIEW OF OBJECTRELATIONAL MODEL
Allow of nested relations
Repeating movies inside the stars
records is redundancy
To avoid redundancy, use
pointers (references)
Introduction to Testing
SUPPORT FROM VENDORS
Several major software companies including IBM, Informix, Microsoft, Oracle, and Sybase
have all released object-relational versions of their products
Extended SQL standards called SQL-99 or SQL3
Introduction to Testing
SQL-99: QUERY LANGUAGE FOR OBJECTRELATIONAL MODEL
User-defied types (UDT) replace the concept of classes
Create relations on top of the UDTs
Multiple relations can be created on top of the same UDT
Create Type <name > as (attributes and method declarations)
Introduction to Testing
CREATING UDT
Introduction to Testing
COLLECTIONS AND LARGE OBJECTS
Book Type contains collections
Arrays of authors -> capture the order of authors
Set of keywords
Large object types:
CLOB: Character large objects book-review CLOB(10KB)
BLOB: binary large objects”
image BLOB(10MB)
movie BLOB(2GB)
Introduction to Testing
CREATING RELATIONS
Once types are created, we can create relations
In general, we can create tables without types
But types provide encapsulation, inheritance, etc.
Introduction to Testing
CREATING RELATIONS
• A single primary key can be defined using Primary Key keyword .
• To reference another relation R, R has to be referenceable using REF keyword
Introduction to Testing
DEFINING RELATIONSHIPS
One-to-many Or one-to-one
• Plug it inside the existing types
Many-to-many
• Create a new type or new table referencing existing types
Introduction to Testing
WHAT’S NEXT
First Approach: Object-Oriented Model
Concepts from OO programming languages
ODL: Object Definition Language
What about querying OO databases???
OQL: Object Oriented Query Language
Second Approach: Object-Relational Model
Conceptual view
Data Definition Language (Creating types, tables, and relationships)
Querying object-relational database (SQL-99)
Introduction to Testing
QUERYING OBJECT-RELATIONAL DATABASE
Most relational operators work on the object-relational tables
E.g., selection, projection, aggregation, set operations
Some new operators and new syntax for some existing operators
SQL-99 (SQL3): Extended SQL to operate on objectrelational database
Introduction to Testing
EXAMPLES I
Introduction to Testing
EXAMPLES II: DE-REFERENCING
Introduction to Testing
WHEN TO CONSIDER OODBMS OR ORDBMS
Complex Relationships
A lot of many-to-many relationships, tree structures or network (graph) structures.
Complex Data
Multi-dimensional arrays, nested structures, or binary data, images, multimedia, etc.
Distributed Databases
Need for free objects without the rigid table structure.
Repetitive use of Large Working Sets of Objects
To make use of inheritance and reusability
Expensive Mapping Layer
Expensive decomposition of objects (normalization) and recomposition at query time
Introduction to Testing
KEY BENEFITS OF ODBMS
Persistence & Versioning
Created objects are maintained across different database runs (persistent)
Different evolving copies of the same object can be created over time (versioning)
Introduction to Testing
KEY BENEFITS OF ODBMS (CONT’D)
• Sharing in highly distributed environment
• Easier to share and distribute objects than tables
Introduction to Testing
KEY BENEFITS OF ODBMS (CONT’D)
Better memory usage and less paging
Bringing only objects of interest
Introduction to Testing
OBJECT-ORIENTED VS. OBJECTRELATION
Object-oriented DBMSs
Did not achieve much success (until now) in the market place
No query support (Indexing, optimization)
No security layer
Object-relational DBMSs
Better support from big vendors
Tries to make use of all advances in RDBMSs
Indexes, views, triggers, query optimizations, security layer, etc.
• Work in progress --- Long way to go
Introduction to Testing
COMPARISON
Introduction to Testing