31
Object-relational databases

PPT

  • View
    853

  • Download
    0

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: PPT

Object-relational databases

Page 2: PPT

Outline What is an ORDBMS ? Need for ORDBMSs Characteristics of an ORDBMS SQL3 – ‘object-oriented’ SQL State of the art: Oracle 8 and IBM DB2

UDB References

Page 3: PPT

What is an ORDBMS ?A combination of:

(1) OO features Complex objects Functions Inheritance and overloading

AND

(2) RDBMS features Tables, views Transactions, recovery, indexing, optimization SQL queries

Page 4: PPT

A brief look at the object-relational model Add ‘object oriented-ness’ to tables

Data is still stored in tables

Support for abstract data types, complex objects & user defined functions allows complex relationships and data to be stored and queried

SQL3 (‘object-oriented’ SQL) is the language for data definition, manipulation, and query.

Page 5: PPT

Need for the O-R approach

Relational DBMS

Object-relational DBMS

File System Object-Oriented DBMS

Simple Data Complex Data

No Query

Query

Page 6: PPT

Need for the O-R approach..

New data types are appearing (e.g., multimedia)Real-world data doesn't fit neatly into tables

Entities and relationships (vs. tables) Variance among entities (vs. homogeneity) Set-valued attributes (vs. normalization)

Advanced applications bring complex data E.g., CAD/CAM data management, web data

management, geographic information management, medical data management

So maybe objects are the answer...?Yes, if we can keep all the relational "goodies"!

Page 7: PPT

Characteristics of object-relational databases SQL support for Base Data Type ExtensionBase Data Type Extension

SQL support for Complex ObjectsComplex Objects

SQL support for InheritanceInheritance

Support for a production Rule SystemRule System

Page 8: PPT

Base Data Type Extension1. Creating a new base data type:

Create type my_type (internallength = 8,

input = mytypeInput, output = mytypeOutput);

Create table my_table (name varchar(20) , some_data my_type);

Page 9: PPT

Base Data Type Extension..2. Creating a user defined function: create function hourly_pay(int) returns

float as select ($1/2000);

Function usage: Select name from emp where hourly_pay(salary) >12.50;

Functions can also be defined in C, Java and used in SQL queries.

Page 10: PPT

Additional requirements Dynamic linking of user-defined

functions Client or Server Activation of

user-defined functions Secure User-Defined Functions Arbitrary-length data types

Page 11: PPT

Complex objects Type constructors:

Composites (records) Sets References

Page 12: PPT

Compositescreate type phone_t ( area varchar(3), number

varchar(3), description varchar(20));

create type dept_t (dname varchar(30), floorint, phone phone_t, manager varchar(30),

manager_ref ref(employee_t));

Usage:create table dept of type dept_t;

Page 13: PPT

SQL extensions needed for composite types1. User-defined functions take arguments or return a result

of a composite type.

e.g.: select sum_digits(phone) from dept where dname = ‘HR’;

2. Functions returning a composite type can appear in the from clause of an SQL query.

3. The ‘cascaded dot notation’ references attributes of a composite object.

e.g.: select phone.number from dept where dname = ‘HR’;

These extensions are also required for sets of composites.

Page 14: PPT

References References are a substitute for the

primary key-foreign key concept. The manager_ref column is a reference

(pointer) to a record of type employee_t.

SQL extensions needed: A deref function that returns the composite Allow functions to take arguments or return

results of type reference.

Page 15: PPT

Inheritance Inheritance only applies to types.

Data inheritance example:create type person_t(name varchar(20));

create type student_t (gpa float, address varchar(10)) under person_t;

create type employee_t(salary int, department varchar(20), address varchar(60)) under person_t;

create type student_employee_t(percent float) under employee_t,student_t;

Page 16: PPT

Inheritance hierarchyperson_t

employee_t student_t

student_emp_t

Page 17: PPT

Ambiguity: ‘Address’ appears in both student_t and employee_t types.

Alternatives: Redefine the address field in one of

super types Database administrator resolves the

ambiguity.

Page 18: PPT

Table hierarchyperson

emp student

student_emp

Select name from emp where salary = 10000; will examine ‘emp’ and ‘student_emp’ tables.

To examine ONLY the ‘emp’ table:Select name from only(emp) where salary = 10000;

Page 19: PPT

Function inheritanceperson_t

employee_t student_t

student_emp_t

Overpaid

Query:Select e.name from emp e where overpaid(e);is evaluated on the emp and student_emp tables.

The student_emp_t type inherits the overpaid function from employee_t.

Overpaid

Overpaid

Page 20: PPT

Production Rule system1. Update update rule (triggers)2. Query update rule3. Update query rule4. Query query rule

Drawbacks: Multiple rules fired by 1 event Chain rules cause infinite loops Aborting action part of a rule terminates whole

transaction

Page 21: PPT

The SQL3 standard An ANSI, ISO standard

Object-oriented features added to SQL2

The foundation for ORDBMS products such as Oracle8 and DB2 UDB

New data types LOB (large object) Composite types: ROW and ARRAY

New predicates: SIMILAR DISTINCT

Page 22: PPT

SQL3 Object oriented extensions to

SQL3: Support for structured user-defined

types Support for user-defined functions Support for triggers Support for references

Page 23: PPT

IBM DB2 UDBOSF (Object Strike Force) group at IBM Almaden

Focus: O-R extensions in DB2 Universal Database version 5.2

V5.2 of UDB contains new O-R features Structured types with inheritance Object tables and table hierarchies References and path expressions Object views and view hierarchies

Page 24: PPT

New O-R features in DB2 UDB 5.2Structured types and references

Named types with attributes, O-O subtyping model Ref(T) for directly modelling relationships

Typed tables and table hierarchies Oid (user-provided) plus a column per attribute of T Subtables for querying and managing subtype instances

Query language extensions Substitutability for queries/updates (data independence +

+) Path expressions for querying relationships easily Functions/predicates for runtime type inquiries

Object views (via a novel approach) Virtual table hierarchies for flexible access control Also facilitates O-O views of legacy tables

Page 25: PPT

Object views in DB2 UDB

vdeptvperson

vemp vstudentdept

mgr

create type VPerson_t as ( name Varchar(40));

create type VEmp_t under VPerson_t as (dept Ref(VDept_t));

create type VStudent_t under VPerson_t as (kind Varchar(8));

create type VDept_t as ( name Varchar(20), mgr Ref(VEmp_t));

Page 26: PPT

Typed view hierarchiesNow create typed views (and subviews)

create view vperson of VPerson_t (ref is oid user generated) as select VPerson_t(Varchar(oid)), name from only (person);

create view vemp of VEmp_t under vperson (dept with options scope vdept) as select VEmp_t(Varchar(oid)), name, VDept_t(Varchar(dept)) from emp where salary > 0;

create view vstudent of VStudent_t under vperson as select VStudent_t(Varchar(oid)), name, case when major like '%Engineer%' then 'Geek' else 'non-Geek' end from student;

create view vdept of VDept_t ...;

Page 27: PPT

Oracle 8 Claimed as “object-enabled”

RDBMS.

Oracle takes an evolutionary approach to object-orientation. In general, Oracle supports OO with a special layer on top of the relational database.

Page 28: PPT

O-O features

1. User-Defined datatype (UDT)2. User-Defined function (UDF)3. Object View and Object Cache,

Object Type Translator

Page 29: PPT

Summary Applications that have complex data and

queries should use ORDBMSs. Major vendors (Oracle, DB2, Illustra)

have ORDBMS products A better and standardized solution to the

multiple inheritance problem is needed. Commercial ORDBMS products should

conform to SQL3, not just support variants of it – interoperability issues.

Page 30: PPT

References1. Object-Relational DBMSs The Next Great Wave – Michael Stonebraker2. SQL:1999, formerly known as SQL3 Andrew Eisenberg, Jim Melton3. O-O, What are they doing to Relational databases? Michael J. Carey IBM Almaden January 19994. Modeling Object Relational Databases, DBMS April 19985. Object Database vs. Object-Relational Databases Steve McClure IDC Bulletin #14821E - August

1997

Page 31: PPT

Questions ?