Title: Object Databases
1Object Databases
- David Nelson
- CAT
- March 2003
2Contents
- Relational DBMS
- Suitability, Complex Applications, Inadequacies
- Data Model Generations
- Types of Object Database
- Object Oriented Databases
- OQL
- Object Relational Databases
- SQL3
- Oracle
- Advantages/Disadvantages
- Why more than one model?
- Summary and Further Reading
3Relational DBMS Suitability
- Relational DBMS are suitable for certain types of
applications - simple data types, e.g. dates, strings
- large number of instances, e.g. students,
employees - well defined relationships between data, e.g.
student, course relationships and use of joins - short transactions, e.g. simple queries
- Most successful for business applications
- On-line transaction processing
4Complex Applications
- CAD, CAM
- complex objects
- graphics
- a large number of types but few instances of each
type - hierarchical design not static
- CASE
- software development lifecycle
- co-operative engineering
- concurrent sharing of design
- code/documentation
5Complex Applications
- Office Information and Multimedia Systems
- e-mail support
- documentation
- SGML documents
- Geographic Information Systems
- spatial and temporal information, e.g.
satellite/survey photos, maps - pattern recognition
6RDBMS Inadequacies
- Poor separation of real world entities
- normalisation leads to entities that dont
closely match real world - joins costly
- Semantic overloading
- all data held as relationships
- no mechanism for differentiation between entities
and relationships - Poor support for integrity and enterprise
constraints - relational systems good for supporting
referential, entity and simple business
constraints - not good for more complex enterprise constraints
7RDBMS Inadequacies
- Homogeneous data structure
- data pushed into rows and columns
- not all real world data can be organised in this
way - Limited operations
- SQL does not allow new operations to be defined
- e.g. select age from person
- Difficulty handling recursive queries
- e.g. find all ancestors
8RDBMS Inadequacies
- Impedance mismatch
- need to embed SQL to get computational
completeness - data types in SQL and programming language dont
match - Concurrency, schema changes and poor navigational
access - no support for long duration transactions
- difficult to change schema, e.g. add columns to a
table - RDBMS based on content based access
- Not navigational
9Data Models
- 1st Generation
- 2nd generation
- 3rd
- generation
10Object-Oriented Databases
- Object-Oriented Database
- e.g. ObjectStore, Objectivity, Jasmine, POET
- based on object-oriented programming techniques
- include concepts such as
- user extensible type system, complex objects,
encapsulation, inheritance, polymorphism, dynamic
binding, object identity - ODMG standard being devised to define data model
and query language standard - also defines interoperability between ODMG
compliant systems
11OQL Example ODL Schema
- class Student
- (extent students)
-
- attribute short id
- attribute string name
- attribute string address
- attribute date dob
- relationship setltModulegt takes
- inverse Module takenby
- short age()
-
12OQL Example ODL Schema
- class Module
- (extent modules)
-
- attribute string title
- attribute short semester
- relationship setltStudentgt takenby
- inverse Student takes
-
- class Postgrad extends Student
- (extent postgrads)
-
- attribute string thesis_title
-
13Object Query Language
- e.g. select distinct x.age
- from Persons x
- where x.name Pat
- Return literal of type setltstructgt
- select distinct struct(a x.age, s x.sex)
- from Persons x
- where x.name Pat
14OQL Examples
- Path Expressions
- select c.address
- from Persons p, p.children c
- where p.address.street Main Street
- and count(p.children) gt 2
- and c.address.city ! p.address.city
- Methods
- select max(select c.age from p.children c)
- from Persons p
- where p.name Paul
15Object-Relational Databases
- Object-Relational Database
- e.g. Oracle 8, Informix, Illustra
- extend relational model with OO features
- e.g. polymorphism, complex objects, extensibility
- but keep relationally based
- SQL99 standard developed as an object-relational
version of SQL92 - Previously known as SQL-3
16SQL99
- Row types
- a data type that can represent types of rows in
tables - e.g.
- CREATE TABLE branch(
- Bno VARCHAR(3),
- address ROW(
- street VARCHAR(25),
- town VARCHAR(15),
- pcode ROW( city_id VARCHAR(4)
- subpart VARCHAR(4))))
- INSERT INTO branch
- VALUES(B5, (22 Deer Rd, Sidcup, (SW1,
4EH)))
17SQL99
- UDTs
- abstract data types
- consists of one or more attribute defns
- encapsulation supported
- CREATE TYPE person_type AS (
- PRIVATE
- date_of_birth DATE CHECK(date_of_birth gt DATE
1990-01-01) - PUBLIC
- fname VARCHAR(15) NOT NULL,
- lname VARCHAR(15) NOT NULL,
- FUNCTION get_age (P person_type) RETURNS
INTEGER - RETURN / code to calc age /
- END ...
- END) NOT FINAL
18SQL99
- User defined routines (UDR)
- may be defined as part of a UDT or as part of a
schema - can be a procedure, function or iterative routine
- Can be written in SQL or in an external
programming language
19SQL99 Examples
- Querying
- uses SQL92 syntax with extensions to handle
objects - e.g.
- SELECT s.lname, s.get_age
- FROM staff s
- WHERE s.is_manager
- SELECT p.lname, p.address
- FROM person p
- WHERE p.get_age gt 65
- SELECT p.lname, p.address
- FROM ONLY (person) p
- WHERE p.get_age gt 65
20SQL99
- Reference Types and OID
- system generated, type REF
- reference types can be used to define
relationships between row types - reference types uniquely identify rows
- allows rows to be shared across tables
- complex joins can be replaced by simple path
expressions - reference types do not provide referential
integrity - Collection types
- ARRAYs, LISTs, SETs, MULTISETs
21SQL99
- Persistent Stored Modules
- SQL3 now computationally complete
- New statements added
- Assignment
- IF .. THEN .. ELSE .. ENDIF, and CASE
- REPEAT BLOCKS
- CALL and RETURN for invoking procedures
- Condition handling
- Triggers
- Triggering events include insertion, deletion and
update of rows in a table
22Oracle 8
- An object-relational extension to Oracle 7
- Object types can be used to create object tables
with object identifiers - attributes
- methods
- Does not support object or table hierarchies
- Oracle 9 supports object hierarchies
- Postgres supports table hierarchies
- New types
- VARRAYs and nested tables
- REFs
- LOBs
23Object Database Advantages
- Enriched modelling capabilities
- can model both state and behaviour
- models real world more naturally
- Extensibility
- ability to build new types and use in system
- abstract data types
- Removal of impedance mismatch
- single language interface between DML and
programming language - computationally complete
24Object Database Advantages
- More expressive query language
- support for navigational queries
- support for methods
- Support for schema evolution
- tight coupling between data and applications
- generalisation, inheritance
- Support for long duration transactions
- RDBMS enforce serializability
25Object Database Advantages
- Applicability to advanced database applications
- CAD, CAM, GIS, etc.
- Improved performance
- improved performance for engineering problems
- but different type of problem
26Object Database Disadvantages
- Lack of universal data model
- RDBs based on set theory
- OODBs lack theoretical basis
- Lack of experience
- limited use
- steep learning curve
- geared towards programmers rather than typical
users - Lack of standards
- ODMG standard evolving for standard data model
and standard query language
27Object Database Disadvantages
- Query optimisation compromises encapsulation
- need to break encapsulation to optimise queries
- e.g. access a private attribute to speed-up query
- Locking at object level may impact performance
- e.g. locking large inheritance hierarchies
- Complexity
- expensive
- difficult to use
28Object Database Disadvantages
- Lack of support for views
- an important concept in RDBs
- provide customisable views of a database
- Lack of support for security
- no views
- coarse granularity
- difficult to grant access rights on individual
objects/classes
29Object-Relational Advantages
- Weaknesses of RDBMS
- Reuse and Sharing
- extending the DBMS server to perform standard
functionality centrally - functionality shared by all applications
- Evolutionary rather than revolutionary
- SQL3 upwardly compatible with current SQL
standard
30Object-Relational Disadvantages
- Complexity and Associated Increased Costs
- simplicity and purity of relational model is lost
- majority of applications do not achieve optimal
performance - Semantic gap between object-oriented and
relational - OO applications not as data centric as Relational
- Objectives of Initial SQL standard were to
minimise user effort and be easy to learn
31Why more than one model?
- Stonebraker proposed a four quadrant view of the
database world
Search capabilities/ multi-user support
Data complexity/extensibility
32Summary
- More than one data model, but each model good for
particular types of application - Each has its own advantages and disadvantages
- Object-Relational DBMS are taking over Relational
DBMS in market place - e.g. Oracle 8
- Object-Oriented still have their own niche
- E.g. CAD, CASE, etc.
33Further Reading
- Connelly and Begg, chapters 21-23
- a very good introduction to object-oriented and
object-relational databases - Cattell, et. al. The Object Data Standard, 3rd
ed. - Discusses the ODMG standard for object databases
- Stonebraker, Object-Relational Databases The
Next Great Wave - written by the person who produced the first
object-relational database Postgres
34Further Reading
- OO Manifesto
- http//citeseer.nj.nec.com/atkinson89objectoriente
d.html - OR Manifesto
- http//citeseer.nj.nec.com/for90thirdgeneration.ht
ml