oodbms&ordbms

Upload: mohan-khedkar

Post on 04-Jun-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 OODBMS&ORDBMS

    1/43

    Object (and Object-Relational)

    Database Systems (part two)CSS263 Lecture 18

  • 8/13/2019 OODBMS&ORDBMS

    2/43

    LECTURE PLAN

    OBJECT DATABASE SYSTEMS

    PART TWO

    What is an OODBMS?

    Advantages and Disadvantages of OODBMSs

    What is an ORDBMS?

    What is SQL3?

    Comparison of OODBMSs and ORDBMSs

    When to use an OODBMS

    When to use an ORDBMS

  • 8/13/2019 OODBMS&ORDBMS

    3/43

    REMINDER OF THE PROBLEMS

    ASSOCIATED WITH AN RDBMS

  • 8/13/2019 OODBMS&ORDBMS

    4/43

    RELATIONAL DBMSs

    Poor representation of real world entities.

    Semantic overloading.

    Poor support for integrity and business constraints.

    Homogeneous data structure.

    Limited operations.

    Difficulty handling recursive queries.

    Impedance mismatch.

    Difficulty with Long Transactions.

    PROBLEMS

  • 8/13/2019 OODBMS&ORDBMS

    5/43

    WHAT IS AN OODBMS?

  • 8/13/2019 OODBMS&ORDBMS

    6/43

    OODBMS

  • 8/13/2019 OODBMS&ORDBMS

    7/43

    OODBMS

    WHAT IS AN OODBMS?

    Object Oriented Database Management Systems (OODBMSs) are an attempt

    at marrying the power of Object Oriented Programming Languages with the

    persistence and associated technologies of a DBMS.

    OOPLs DBMSs

    Complex Objects Persistence

    Object Identity Disc Management

    Methods & Messages Data Sharing

    Inheritance ReliabilityPolymorphism Security

    Extensibility Ad Hoc Querying

    Computational Completeness

    OBJECT ORIENTED DATABASE MANAGEMENT SYSTEM

  • 8/13/2019 OODBMS&ORDBMS

    8/43

  • 8/13/2019 OODBMS&ORDBMS

    9/43

    REQUIREMENTS AND FEATURES

    OODBMSs

    Requirements:

    Transparently add persistence to OO programming languages

    Ability to handle complex data - i.e., Multimedia data

    Ability to handle data complexity - i.e., Interrelated data items

    Add DBMS Features to OO programming languages

    Features:

    The host programming language is also the DML.

    The in-memory and storage models are merged.

    No conversion code between models and languages is needed.

  • 8/13/2019 OODBMS&ORDBMS

    10/43

    TWO-LEVEL STORAGE MODEL FOR A RDBMS

    SQL

    Transforming and

    type checking

    Main or virtualmemory

    Secondary

    storage

  • 8/13/2019 OODBMS&ORDBMS

    11/43

    Record

    Record

    Record

    3. Access object

    4. Copy modified fields 2. Copy relevant fields

    5. Save page 1. Read page

    Page

    Page

    Page

    ACCESSING A RECORD USING AN RDBMS

  • 8/13/2019 OODBMS&ORDBMS

    12/43

    Main or virtual

    memory

    Secondary

    storage

    SINGLE-LEVEL STORAGE MODEL

    FOR AN OODBMS

  • 8/13/2019 OODBMS&ORDBMS

    13/43

    3. Access object

    5. Save page 1. Read page

    Page

    Page

    Object

    Object

    4. Swizzle pointers

    back, etc.

    2. Swizzle

    pointers, etc.

    ACCESSING AN OBJECT USING AN OODBMS

  • 8/13/2019 OODBMS&ORDBMS

    14/43

    ADVANTAGES AND DISADVANTAGES OF

    AN OODBMS?

  • 8/13/2019 OODBMS&ORDBMS

    15/43

    ADVANTAGES

    OODBMSs

    Enriched modelling capabilities

    Extensibility

    Removal of Impedance Mismatch

    Support for schema evolution.

    Support for long duration transactions.

    Applicable for advanced database applications

    Improved performance.

  • 8/13/2019 OODBMS&ORDBMS

    16/43

    DISADVANTAGES

    OODBMSs

    Lack of a universal data model

    Lack of experience

    Lack of standards.

    Ad-hoc querying compromises encapsulation.

    Locking at object-level impacts performance

    Complexity

    Lack of support for views

    Lack of support for security

  • 8/13/2019 OODBMS&ORDBMS

    17/43

  • 8/13/2019 OODBMS&ORDBMS

    18/43

    WHAT IS AN ORDBMS?

    In essence ORDBMSs are an attempt

    to add OO to Tables!

    ORDBMSs

    Definition:

    Object-Relational databases extend the Relational Data Model

    to address those weaknesses identified previously.

    An Object-Relational database adds features associated with

    object-oriented systems to the Relational Data Model.

  • 8/13/2019 OODBMS&ORDBMS

    19/43

    MAJOR DIFFERENCE BETWEEN AN

    ORDBMS AND AN OODBMS

    OODBMSs try to add DBMS functionality to one

    or more OO programming languages.

    ORDBMSs

    REVOLUTIONARYIN THAT THEY ABANDON SQL

    ORDBMSs try to add richer data types and OO

    features to a relational DBMS.

    EVOLUTIONARYIN THAT THEY EXTEND SQL

  • 8/13/2019 OODBMS&ORDBMS

    20/43

    SQL3

  • 8/13/2019 OODBMS&ORDBMS

    21/43

    WHAT IS SQL3?

    ORDBMSs

    SQL3 or SQL/99:

    SQL3 is a superset of SQL/92, in that it supports all

    of the constructs supported by that standard, as well

    as adding new ones of its own.

    Therefore, whatever worked in an implementation of

    SQL/92 should also work in an implementation of

    SQL3.HOWEVER, IT SHOULD BE NOTED THAT AS YET

    THERE ARE NO IMPLEMENTATIONS OF SQL3!

  • 8/13/2019 OODBMS&ORDBMS

    22/43

    WHAT IS NEW IN SQL3?

    ORDBMSs

    Extended Base Types.

    Row Types.

    User-Defined Types.

    User-Defined Routines.

    Sub-Types and Super-Types.

    Sub-Tables and Super-Tables.

    Reference Types and Object Identity.

    Collection Types.

  • 8/13/2019 OODBMS&ORDBMS

    23/43

    SQL3 - EXTENDED BASE TYPES

    ORDBMSs

    ONE OF THE REASONS FOR THE MOVE AWAYFROM RDBMSs IS THE LIMITED BASE TYPE

    AVAILABILITY:

    BASE TYPES AVAILABLE IN SQL/92 INCLUDE:

    NUMBER, CHAR, DATE, ...

    BASE TYPES IN SQL3 ARE EXTENSIBLE. THEREFORE THE

    FOLLOWING MUCH NEEDED TYPES COULD BE ADDED

    (PROVIDED SOMEBODY CREATES THEM!)

    VIDEO, IMAGE, AUDIO, TEXT, SPATIAL, TEMPORAL,

    GEOGRAPHIC, WEB-PAGES, ...

    O S

  • 8/13/2019 OODBMS&ORDBMS

    24/43

    SQL3 - ROW TYPES

    ORDBMSs

    CITYAREASTREET

    ADDRESS

    OXFORDMARSDENHIGH ST.30

    LONDONLEYTONHIGH RD.20

    LONDONBARKINGMAIN ST.10

    BRANCHNO

    CREATE TABLE branch(

    branchno VARCHAR(3),address ROW( street VARCHAR(25),

    area VARCHAR(15),

    city VARCHAR(15));

    COLUMN ATTRIBUTES NO LONGER HAVE TO BE ATOMIC!

    ORDBMS

  • 8/13/2019 OODBMS&ORDBMS

    25/43

    SQL3 - USER-DEFINED TYPES

    ORDBMSs

    CREATE TYPE person_typeAS (PRIVATE

    date_of_birth DATE

    CHECK (date_of_birth > DATE 1900-01-1901),

    PUBLIC

    name VARCHAR(15) NOT NULL,address VARCHAR(50) NOT NULL,

    tel_no VARCHAR(13) NOT NULL,

    FUNCTION get_age(P person_type)

    RETURNS INTEGER

    /* code to calculate age from date_of_birth */RETURN

    END)

    NOT FINAL;

    An example of a User-Defined Routine (UDR)

    ORDBMS

  • 8/13/2019 OODBMS&ORDBMS

    26/43

    SQL3 - SUB-TYPES & SUPER-TYPES

    ORDBMSs

    PERSON-TYPE

    date of birth

    name

    address

    tel-no

    get_age()

    STAFF-TYPE

    snoposition

    salary

    branch

    is_manager()

    Sub-Types and Super-Types are used to

    allow for INHERITANCEin SQL3

    A Sub-Type can inherit from more thanone Super-Type.

    Multiple Inheritance is allowed!

  • 8/13/2019 OODBMS&ORDBMS

    27/43

    ORDBMS

  • 8/13/2019 OODBMS&ORDBMS

    28/43

    SQL3 - TYPES & TABLES

    ORDBMSs

    In order to remain upwardly compatible with SQL-92,

    TYPES can ONLYbe instantiated through SQL Tables!

    Therefore, in order to create instances of a type we first have

    to create a table to store those instances in!

    CREATE TABLE staff OF STAFF_TYPE (

    PRIMARY KEY sno);

    EXAMPLE:

    In order to create staff instances we first have to do one of the following:

    CREATE TABLE staff (

    info STAFF_TYPE,

    PRIMARY KEY sno);

    ORDBMS

  • 8/13/2019 OODBMS&ORDBMS

    29/43

    SQL3 - SUB-TABLES & SUPER-TABLES

    ORDBMSs

    PROBLEM - What happens if we create two or more tables

    for the same TYPE? How do we find all TYPE instances?

    CREATE TABLE lecturer OF STAFF_TYPE (PRIMARY KEY sno);

    EXAMPLE: FIND ALL MEMBERS OF STAFF!

    CREATE TABLE admin OF STAFF_TYPE (

    PRIMARY KEY sno);

    The only way of doing this is to declare the lecturer and

    admin tables as sub-tables of a staff super-table!

    ORDBMS

  • 8/13/2019 OODBMS&ORDBMS

    30/43

    SQL3 - SUB-TABLES & SUPER-TABLES

    ORDBMSs

    CREATE TABLE lecturer OF STAFF_TYPE UNDERstaff(

    PRIMARY KEY sno);

    CREATE TABLE admin OF STAFF_TYPE UNDERstaff(

    PRIMARY KEY sno);

    CREATE TABLE staff OF STAFF_TYPE (

    PRIMARY KEY sno);

    SUPER-TABLE

    SUB-TABLES

    SOLUTION TO PROBLEM (FIND ALL STAFF):

    SQL>SELECT * FROM staff;

    ORDBMS

  • 8/13/2019 OODBMS&ORDBMS

    31/43

    SQL3 - REFERENCE TYPES AND OIDS

    ORDBMSs

    A Reference Type is the SQL3 equivalent of an OID in an OODBMS.

    Reference Types allow a row to be shared among multiple tables, and

    enable users to replace complex join operations with path expressions!

    CREATE TYPE staff_typeUNDER person_typeAS (

    sno VARCHAR(5) NOT NULL UNIQUE,

    position VARCHAR(10) NOT NULL,

    salary NUMBER(7,2),

    next_of_kin REF(person_type)

    bno VARCHAR(3) NOT NULL)

    NOT FINAL;

    CREATE TABLE person OF person_type(

    oid REF(person_type) VALUES ARE SYSTEM GENERATED);

    EXAMPLE:

    Could point to a row in ANY

    table containing a person_type!

    ORDBMS

  • 8/13/2019 OODBMS&ORDBMS

    32/43

    SQL3 - REFERENCE TYPES AND OIDS

    ORDBMSs

    To ensure that a REFERENCE is limited to a single table, a SCOPEhas to be added to the table using the REFERENCE!

    CREATE TYPE staff_typeUNDER person_typeAS (

    sno VARCHAR(5) NOT NULL UNIQUE,

    position VARCHAR(10) NOT NULL,

    salary NUMBER(7,2),

    next_of_kin REF(person_type)

    bno VARCHAR(3) NOT NULL)

    NOT FINAL;

    CREATE TABLE person OF person_type(

    oid REF(person_type) VALUES ARE SYSTEM GENERATED);

    EXAMPLE:

    CREATE TABLE staff OF staff_type(

    PRIMARY KEY sno,

    SCOPEFOR next_of_kin IS person);

    staff next_of_kinwill point

    to a row in the person table!)

    ORDBMS

  • 8/13/2019 OODBMS&ORDBMS

    33/43

    SQL3 - COLLECTION TYPES

    ORDBMSs

    List(base) - ordered collection allows duplicates

    Array(base) - one-dimensional array, max no.

    Set(base) - unordered collection, no duplicates

    Multiset(base) - unordered collection, allows duplicates

    SQL3 COLLECTION TYPES ARE THE EQUIVALENTOF COLLECTION TYPES IN OODBMSs

    KNOWN AS A BAG IN AN OODBMS!

    ORDBMS

  • 8/13/2019 OODBMS&ORDBMS

    34/43

    SQL3 - COLLECTION TYPES

    ORDBMSs

    CREATE TABLE branch (

    bno NUMBER(3),

    address ROW ( street VARCHAR(15),

    area VARCHAR(15),

    city VARCHAR(15)

    staff SET (STAFF_TYPE));

    EXAMPLE

    THE USE OF COLLECTION TYPES WITHIN

    TABLES ENSURE THAT TABLES NO LONGER

    HAVE TO BE IN 1NF

    REPEATING GROUPS ARE ALLOWED!

    ORDBMSs

  • 8/13/2019 OODBMS&ORDBMS

    35/43

    SQL3 - OTHER ADDITIONS

    ORDBMSs

    THE MAIN ADDITIONS TO SQL THAT ARE NOTSPECIFICALLY ASSOCIATED WITH ADDING

    OBJECT-SUPPORT ARE THE FOLLOWING:

    SQL IS NOW COMPUTATIONALLY COMPLETEPERSISTENT STORED MODULES ARE SUPPORTED

    TRIGGERS ARE SUPPORTED

  • 8/13/2019 OODBMS&ORDBMS

    36/43

    OODBMS or ORDBMS?

    OODBMS or ORDBMS

  • 8/13/2019 OODBMS&ORDBMS

    37/43

    OODBMS or ORDBMS

    CONSIDERATIONS

    OODBMS- put more emphasis on the role of the client, i.e.,

    Client side caching! This can radically improve long, process

    intensive, transactions.

    ORDBMS- SQL is still the language for data definition,manipulation and queryStill have Impedance Mismatch!

    OODBMSshave been optimised to directly support object-

    oriented applications and specific OO languages.

    ORDBMSsare supported by most of the major players in the

    DBMS market place.

    OODBMS or ORDBMS

  • 8/13/2019 OODBMS&ORDBMS

    38/43

    OODBMS or ORDBMS

    CONSIDERATIONS

    ORDBMS- Most third-party database tools are written for

    the relational model (SQL-92), and will therefore be

    backward-compatible with SQL3.

    ORDBMS- search, access and manipulate complex data types

    in the database with standard SQL (SQL3), without breaking

    the rules of the relational data model.

    OODBMSThe ODMG standard groups OQL is now the

    de-facto query language amongst OODBMS vendors.However, in order to use it, collection objects (known as

    extents) have to first be created for each class.

    OODBMS or ORDBMS

  • 8/13/2019 OODBMS&ORDBMS

    39/43

    OODBMS or ORDBMS

    CONSIDERATIONS

    OODBMS- In order to realise the value of an OODBMS you

    must build your application using methods written in one of

    several object-oriented language (i.e. C++, Java, Smalltalk).

  • 8/13/2019 OODBMS&ORDBMS

    40/43

    WHEN TO USE AN OODBMS

    OODBMS or ORDBMS

  • 8/13/2019 OODBMS&ORDBMS

    41/43

    WHEN TO USE AN OODBMS

    OODBMS or ORDBMS

    In applications that generally retrieve relatively few(generally physically large) highly complex objects

    and work on them for fairly long periods of time.

    This will necessitate the use of client caching,

    pointer swizzling, and non-locking forms ofconcurrency control.

  • 8/13/2019 OODBMS&ORDBMS

    42/43

    WHEN TO USE AN ORDBMS

    OODBMS or ORDBMS

  • 8/13/2019 OODBMS&ORDBMS

    43/43

    WHEN TO USE AN ORDBMS

    OODBMS or ORDBMS

    In applications that process a large number of short-lived (generally ad-hoc query) transactions on data

    items that can be arbitrarily complex in structure.

    Where the main emphasises is on efficient query

    optimisation to limit disk accesses, and traditionalconcurrency control is acceptable.