Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database...

63
Object oriented Object oriented Database Database Prof. Sin-Min Lee Prof. Sin-Min Lee
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    258
  • download

    13

Transcript of Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database...

Page 1: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Object oriented Object oriented DatabaseDatabase

Prof. Sin-Min LeeProf. Sin-Min Lee

Page 2: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Database Management Systems

Database ModelsDatabase Models Relational DatabaseRelational Database Object Oriented Database ModelObject Oriented Database Model Deductive Database ModelDeductive Database Model Hierarchial Database ModelHierarchial Database Model Network Datbase ModelNetwork Datbase Model

Page 3: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.
Page 4: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Data Models: 1st Generation

Hierarchical Data ModelHierarchical Data Model implemented primarily by IBM’s Information implemented primarily by IBM’s Information

Management System (IMS)Management System (IMS) allows one-to-one or one-to-many relationships allows one-to-one or one-to-many relationships

between entitiesbetween entities an entity at a “many” end of a relationship can be an entity at a “many” end of a relationship can be

related to only one entity at the “one” endrelated to only one entity at the “one” end this model is this model is navigationalnavigational – data access is through – data access is through

defined relationships, efficient if searches follow defined relationships, efficient if searches follow predefined relationships but performs poorly otherwise, predefined relationships but performs poorly otherwise, e.g for ad-hoc queries.e.g for ad-hoc queries.

Page 5: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Data Models: 1st Generation Network Data ModelNetwork Data Model standard developed by the Committee on Data Systems standard developed by the Committee on Data Systems

Languages (CODASYL)Languages (CODASYL) allows one-to-one or one-to-many relationships between entitiesallows one-to-one or one-to-many relationships between entities allows multiple parentage – a single entity can be at the “many” allows multiple parentage – a single entity can be at the “many”

ends of multiple relationships ends of multiple relationships navigationalnavigational

Page 6: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Database Management Systems

Hierarchial Database ModelHierarchial Database Model Relatively old, dating from 1950’sRelatively old, dating from 1950’s Uses a tree structure such as a company Uses a tree structure such as a company

org chartorg chart President –> VPresident ->Dept1-Dept2-President –> VPresident ->Dept1-Dept2-

Dept3->EmployeesDept3->Employees Can be translated into a linear listCan be translated into a linear list

Page 7: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Database Management Systems

Hierarchial ContinuedHierarchial Continued Data elements organized as tabular rowsData elements organized as tabular rows Each row for each instance of an entityEach row for each instance of an entity Row position implies a relationship to Row position implies a relationship to

other rowsother rows Relationships represented by logical Relationships represented by logical

proximity in the linearized treeproximity in the linearized tree

Page 8: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Database Management Systems

Hierarchial ContinuedHierarchial Continued ExampleExample President ( name = jones, phone =223-3332)President ( name = jones, phone =223-3332)

Vice President ( name = boyd,…)Vice President ( name = boyd,…) Department ( name =marketing)Department ( name =marketing)

• Employee ( name = Smith)Employee ( name = Smith)• Employee(name=Jones)Employee(name=Jones)

Department ( name = manufacturing)Department ( name = manufacturing)• Employee ( name = Williams)Employee ( name = Williams)

Vice President ( name = Graham, phone =345-6789)Vice President ( name = Graham, phone =345-6789) Department ( name =human resources)Department ( name =human resources)

Page 9: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Database Management Systems

Network Database ModelNetwork Database Model Replaces the hierarchial tree with a graph Replaces the hierarchial tree with a graph

network network If employee works for two depts in If employee works for two depts in

previous example the hierarchial model previous example the hierarchial model breaks down.breaks down.

Network model maintains relationships Network model maintains relationships with a system of intersecting chainswith a system of intersecting chains

Page 10: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Database Management Systems

Employee Charlie

Department Electrical

Charlie works for Electrical Department

Other workers

Other departments

Charlie works for

Page 11: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Data Models: 2nd Generation Relational Data ModelRelational Data Model

developed by Edgar Codd (1970)developed by Edgar Codd (1970) data represented by simple tabular structures (relations)data represented by simple tabular structures (relations) relationships defined by primary keys and foreign keysrelationships defined by primary keys and foreign keys data accessed using high-level non-procedural language (SQL)data accessed using high-level non-procedural language (SQL) separates logical and physical representation of dataseparates logical and physical representation of data highly commercially successful (Oracle, DB2, SQL Server, etc)highly commercially successful (Oracle, DB2, SQL Server, etc)

SQL is not computationally completeSQL is not computationally complete does not have the full power of a programming languagedoes not have the full power of a programming language Applications generally require the use of SQL statements Applications generally require the use of SQL statements

embedded in another programming language.embedded in another programming language.

Page 12: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Database Management Systems

Relational Database ModelRelational Database Model Uses tables to organize dataUses tables to organize data Each table corresponds to an entityEach table corresponds to an entity Each row represents an instance of that Each row represents an instance of that

entityentity Each column represents an attribute of Each column represents an attribute of

the entitythe entity Tables can be related to each otherTables can be related to each other

Page 13: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Database Management Systems Relational Model Example:Relational Model Example:SalespeopleSalespeople

SnumSnum SnameSname CityCity CommComm

10011001 PeelPeel LondonLondon .12.12

10021002 SerresSerres San JoseSan Jose .13.13

10041004 MotikaMotika LondonLondon .11.11

Snum= unique number for each salesperson

Sname=name of salesperson

Comm = commission rate

Page 14: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Database Management Systems

Object Oriented Database ModelObject Oriented Database Model Represents an entity as a classRepresents an entity as a class

A class captures both attributes and behaviorA class captures both attributes and behavior Instances of the class are called objectsInstances of the class are called objects Within an object the class attributes take on Within an object the class attributes take on

specific values which distinguish one object specific values which distinguish one object from anotherfrom another

Does not restrict to native data types such as Does not restrict to native data types such as real,integer, can use other objectsreal,integer, can use other objects

Page 15: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Database Management Systems

Object Oriented ExampleObject Oriented Example ClassClass

CatCat AttributesAttributes

Color, weight, breedColor, weight, breed BehaviorBehavior

Scratches, sleeps,purrsScratches, sleeps,purrs An instance of the cat class is an object with specific An instance of the cat class is an object with specific

attributesattributes Example – an attribute of a cat can be owner and the owner Example – an attribute of a cat can be owner and the owner

can be a student objectcan be a student object

Page 16: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Data Models: 3rd Generation most programming languages are now object-orientedmost programming languages are now object-oriented Object Data ModelObject Data Model

offers offers persistencepersistence to objects, including their associations, attributes and to objects, including their associations, attributes and operationsoperations

requirements specified by Atkinson in 1989, standards proposed by requirements specified by Atkinson in 1989, standards proposed by Object Data Management Group (ODMG)Object Data Management Group (ODMG)

navigational – a step backwards from the relational model in some waysnavigational – a step backwards from the relational model in some ways Object-Relational ModelObject-Relational Model

hybrid (or “post-relational”) model – objects can be stored within hybrid (or “post-relational”) model – objects can be stored within relational database tablesrelational database tables

proposed by Stonebraker (1990)proposed by Stonebraker (1990) no accepted standards, but ORDBMS features supported by major no accepted standards, but ORDBMS features supported by major

commercial RDBMSs such as Oraclecommercial RDBMSs such as Oracle

Page 17: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.
Page 18: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.
Page 19: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.
Page 20: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.
Page 21: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.
Page 22: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Database Management Systems

DB Designer DB User

Schema Compiler

Storage/Retrieval

Services

User Interface

Operating System

Data Dictionary Data

Page 23: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

SNUMSNUM SNAMESNAME CityCity CommComm

10011001 PeelPeel LondonLondon .12.12

10021002 SerresSerres San JoseSan Jose .13.13

10041004 MotikaMotika LondonLondon .11.11

CNUMCNUM CNAMECNAME CITYCITY RATINGRATING SNUMSNUM

20012001 HoffmanHoffman LondonLondon 100100 10011001

20022002 GiovanniGiovanni RomeRome 200200 10031003

20032003 LiuLiu San JoseSan Jose 200200 10021002

20042004 GrassGrass BerlinBerlin 300300 10021002

ONUMONUM AMTAMT ODATEODATE CNUMCNUM SNUMSNUM

30013001 18.6918.69 10/03/0010/03/00 20082008 10071007

30033003 767.19767.19 10/03/0010/03/00 20012001 10011001

Salespeople

Customers

Orders

Page 24: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Using Databases

Goal of object-oriented design is to model a processGoal of object-oriented design is to model a process Goal of relational database design is normalisationGoal of relational database design is normalisation The mapping from objects to tables can be difficult The mapping from objects to tables can be difficult

if the model contains if the model contains complex class structurescomplex class structures large unstructured objectslarge unstructured objects object inheritance object inheritance

The resulting tables may store data inefficiently, or The resulting tables may store data inefficiently, or access to data may be inefficientaccess to data may be inefficient

Page 25: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Using Databases

There are essentially three approaches which have There are essentially three approaches which have been developed for the management of object been developed for the management of object storage in databases:storage in databases:

the Object-Oriented Database Management the Object-Oriented Database Management SystemSystem (OODBMS) (OODBMS)

the Object-Relational Database Management the Object-Relational Database Management SystemSystem (ORDBMS) (ORDBMS)

Object Relational MappingObject Relational Mapping

Page 26: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Object Relational Mapping

Most business database applications use relational Most business database applications use relational databasesdatabases

Need to map the objects in the application to Need to map the objects in the application to tables in the databasetables in the database

Sometimes be a simple matter of mapping Sometimes be a simple matter of mapping individual classes to separate database tablesindividual classes to separate database tables

However, if the class structure is more complex, However, if the class structure is more complex, then the mapping must be carefully considered to then the mapping must be carefully considered to allow data to be represented and accessed as allow data to be represented and accessed as efficiently as possibleefficiently as possible

Page 27: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Object Relational Mapping

Page 28: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

OR Mapping: Inheritance

Vertical mappingVertical mapping

Page 29: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

OR Mapping: Inheritance Horizontal mappingHorizontal mapping

Page 30: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

OR Mapping: Inheritance Filtered mappingFiltered mapping

Page 31: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

OR Mapping: Guidelines

Use Use VerticalVertical mapping when: mapping when: there is significant overlap between typesthere is significant overlap between types changing types is commonchanging types is common

Use Use HorizontalHorizontal mapping when: mapping when: there is little overlap between typesthere is little overlap between types changing types is uncommonchanging types is uncommon

Use Use FilteredFiltered mapping for: mapping for: simple or shallow hierarchies with little overlap simple or shallow hierarchies with little overlap

between typesbetween types

Page 32: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

OR Mapping: Many-to-Many

Page 33: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Relational, Object-Oriented, and Multidimensional Databases

What is a What is a relationshiprelationship??

p. 535 Fig. 10-20 Next

Connection within data

Click to view animation

Page 34: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Relational, Object-Oriented, and Multidimensional Databases

What is an What is an object-oriented database (OODB)object-oriented database (OODB)??

p. 536 Next

Click to view Web Link,click Chapter 10, Click Web Linkfrom left navigation, then click Object-Oriented Databases below Chapter 10

Advantages

Often uses object query language (OQL)

Stores data in objectsObject is item that contains data, as well as actions that read or process data

Can store more types of dataCan access data faster

Page 35: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Relational, Object-Oriented, and Multidimensional Databases

What are examples of applications appropriate for an What are examples of applications appropriate for an object-oriented database?object-oriented database?

p. 536 Next

Multimedia databasesMultimedia databases

Store images, audio clips, and/or video clips

Store images, audio clips, and/or video clips

Groupware databasesGroupware databases

Store documents such as schedules, calendars, manuals,

memos, and reports

Store documents such as schedules, calendars, manuals,

memos, and reportsComputer-aided design (CAD) databasesComputer-aided design (CAD) databases

Store data about engineering, architectural,

and scientific designs

Store data about engineering, architectural,

and scientific designs

Hypertext databasesHypertext databases

Contain text links to other documentsContain text links to other documents

Hypermedia databasesHypermedia databases

Contain text, graphics, video, and sound

Contain text, graphics, video, and sound

Web databasesWeb databases

Link to e-form on Web pageLink to e-form on Web page

Page 36: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Object Data Model

Object-oriented database systems are based on the Object-oriented database systems are based on the concept of concept of persistent objectspersistent objects

Use class declarations similar to those used by Use class declarations similar to those used by object-oriented programming languagesobject-oriented programming languages

Class declarations should additionally indicate Class declarations should additionally indicate relationships between objects.relationships between objects.

The system must be able to represent traditional The system must be able to represent traditional database relationships and also relationships database relationships and also relationships unique to the object-oriented model, such as unique to the object-oriented model, such as inheritanceinheritance

Page 37: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Object Data Model

Page 38: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Object Identifiers

RDBMSRDBMS entities are uniquely identified by primary keysentities are uniquely identified by primary keys relationships are represented by matching primary key-relationships are represented by matching primary key-

foreign key dataforeign key data Identification Identification depends on the values in the key fieldsdepends on the values in the key fields

Object-oriented database Object-oriented database stores object identifiers (OIDs) within an object to indicate stores object identifiers (OIDs) within an object to indicate

other objects to which it is related.other objects to which it is related. The object identifier is not visible to the user or database The object identifier is not visible to the user or database

programmerprogrammer An object An object remains the same object even when its state takes remains the same object even when its state takes

on completely new valueson completely new values

Page 39: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Object Identifiers The fact that an object’s identity is distinct from its values The fact that an object’s identity is distinct from its values

means that the concepts of equivalence and equality are means that the concepts of equivalence and equality are different:different:

Equivalent:Equivalent: same OIDsame OID Equal:Equal: same state valuessame state values

Equality can exist at different levels:Equality can exist at different levels: Shallow equalityShallow equality same state values (e.g. two same state values (e.g. two

CustomerOrder objects have same values)CustomerOrder objects have same values) Deep equalityDeep equality same state values and related objects also same state values and related objects also

contain same state values (e.g. two contain same state values (e.g. two CustomerOrder objects have same values CustomerOrder objects have same values and all their related OrderItem objects and all their related OrderItem objects

have same values)have same values)

Page 40: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Objects and Literals

Objects can change their state values, and Objects can change their state values, and are described as being are described as being mutablemutable

Another component of the object data Another component of the object data model is the model is the literalliteral, which represents a , which represents a value or set of values which cannot be value or set of values which cannot be changedchanged

A literal is described as being A literal is described as being immutableimmutable. . Literals do not have OIDs.Literals do not have OIDs.

Page 41: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Representation of Relationships

Page 42: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Representation of Relationships

In the diagram all relationships have In the diagram all relationships have inverse inverse relationshipsrelationships. .

Inverse relationships are optional but can be used Inverse relationships are optional but can be used to enforce to enforce relationship integrityrelationship integrity

Without an inverse relationship, there is nothing to Without an inverse relationship, there is nothing to stop an stop an OrderItemOrderItem being referenced by more than being referenced by more than one one OrderOrder

The inverse ensures that an The inverse ensures that an OrderItemOrderItem is is associated with only one associated with only one OrderOrder..

Page 43: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Representation of Relationships Only relationships predefined by storing OIDs can Only relationships predefined by storing OIDs can

be used to query or traverse the databasebe used to query or traverse the database The database is therefore The database is therefore navigationalnavigational Object-oriented databases are generally not as well Object-oriented databases are generally not as well

suited to ad-hoc querying as relational databasessuited to ad-hoc querying as relational databases However, However, performance can be better than a performance can be better than a

relational database for predictable access patterns relational database for predictable access patterns which follow predefined relationshipswhich follow predefined relationships

Page 44: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Relationships: One-Many

unlike relational model, the object data model unlike relational model, the object data model allows multi-valued attributes (known as allows multi-valued attributes (known as setssets and and bagsbags))

class at “many” end has attribute to hold OID of class at “many” end has attribute to hold OID of parent (see OrderItem in the figure above)parent (see OrderItem in the figure above)

class at “one” end has attribute to hold a class at “one” end has attribute to hold a setset of of related OIDs (see CustomerOrder in the figure)related OIDs (see CustomerOrder in the figure)

Page 45: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Relationships: Many-Many

object data model allows direct many-to-object data model allows direct many-to-many relationshipsmany relationships

in contrast, relational model requires the use in contrast, relational model requires the use of composite entities to remove many-to-of composite entities to remove many-to-many relationshipsmany relationships

each class has an attribute to hold a set of each class has an attribute to hold a set of OIDsOIDs

Page 46: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Relationships: “Is A” & “Extends” These relationships can be represented because the object-These relationships can be represented because the object-

oriented paradigm supports inheritanceoriented paradigm supports inheritance For example, a company needs to store information about For example, a company needs to store information about

Employees. There are specific types of employee, such as Employees. There are specific types of employee, such as SalesRep. A SalesRep has an attribute to store a sales area, e.g. SalesRep. A SalesRep has an attribute to store a sales area, e.g. North, WestNorth, West

This situation can be modelled easily in an object-oriented This situation can be modelled easily in an object-oriented system. For example in Java:system. For example in Java:public class Employee {public class Employee {String name;String name;String address;String address;……}}

public class SalesRep extends Employee {public class SalesRep extends Employee {String area;}String area;}

Page 47: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Relationships: “Whole-Part” A whole-part relationship is a many-to-many A whole-part relationship is a many-to-many

relationship with a special meaningrelationship with a special meaning It is useful in a manufacturing database which is used to It is useful in a manufacturing database which is used to

track parts and subassemblies used to create products. track parts and subassemblies used to create products. A product can be made up of many part and A product can be made up of many part and subassemblies. Also, the same part or subassembly can subassemblies. Also, the same part or subassembly can be used in many productsbe used in many products

This type relationship is represented as a many-many This type relationship is represented as a many-many relationship using sets of OIDs in two classesrelationship using sets of OIDs in two classes

This type of relationship is very awkward for a This type of relationship is very awkward for a relational database to represent.relational database to represent.

Page 48: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Orthogonal Persistence Orthogonality can be described by saying that feature A Orthogonality can be described by saying that feature A

is orthogonal to feature B if you don't have to care about is orthogonal to feature B if you don't have to care about feature A while thinking about feature B. feature A while thinking about feature B.

Orthogonal persistence is a form of object persistence Orthogonal persistence is a form of object persistence which adheres to the following principles (Atkinson & which adheres to the following principles (Atkinson & Morrison, 1995):Morrison, 1995):

principle of persistence independence principle of persistence independence programs look the same whether they manipulate long-programs look the same whether they manipulate long-

term or short-term dataterm or short-term data principle of data type orthogonalityprinciple of data type orthogonality

all data objects are allowed to be persistent irrespective all data objects are allowed to be persistent irrespective of their typeof their type

principle of persistence identificationprinciple of persistence identification the mechanism for identifying persistent objects is not the mechanism for identifying persistent objects is not

related to the type systemrelated to the type system

Page 49: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Object Database Standards The Object Oriented Database Manifesto (1989)The Object Oriented Database Manifesto (1989)

Mandatory features:Mandatory features: Complex objectsComplex objects (OO feature) (OO feature)

objects can contain attributes which are themselves objects.objects can contain attributes which are themselves objects. Object identityObject identity (OO) (OO) EncapsulationEncapsulation (OO) (OO) ClassesClasses (OO) (OO) InheritanceInheritance (OO): class hierarchies (OO): class hierarchies Overriding, Overloading, Late BindingOverriding, Overloading, Late Binding (OO) (OO) Computational completenessComputational completeness (OO (OO PersistencePersistence (DB) (DB)

data must remain after the process that created it has terminateddata must remain after the process that created it has terminated Secondary Storage ManagementSecondary Storage Management (DB) (DB) ConcurrencyConcurrency (DB) (DB) RecoveryRecovery (DB) (DB) Ad hoc query facilityAd hoc query facility (DB) (DB)

not necessarily a query language – could be a graphical query toolnot necessarily a query language – could be a graphical query tool

Page 50: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Object Database Standards The ODMG Proposed StandardThe ODMG Proposed Standard One of the crucial factors in the commercial success of RDBMSs is the relative One of the crucial factors in the commercial success of RDBMSs is the relative

standardisation of the data modelstandardisation of the data model The Object Data Management Group (ODMG) was formed by a group of industry The Object Data Management Group (ODMG) was formed by a group of industry

representatives to define a proposed standard for the object data model.representatives to define a proposed standard for the object data model. It is still far from being as widely recognised as the relational database standards. It is still far from being as widely recognised as the relational database standards. The ODMG proposed standard defines the following aspects of an OODBMS:The ODMG proposed standard defines the following aspects of an OODBMS:

basic terminologybasic terminology data typesdata types classes and inheritanceclasses and inheritance objectsobjects collection objects (including sets, bags, lists, arrays)collection objects (including sets, bags, lists, arrays) structured objects (Date, Interval, Time, Timestamp – similar to SQL)structured objects (Date, Interval, Time, Timestamp – similar to SQL) relationshipsrelationships object definition language (ODL)object definition language (ODL) object query language (OQL)object query language (OQL)

Page 51: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Advantages of OODBMS

Complex objects and relationshipsComplex objects and relationships Class hierarchyClass hierarchy No impedance mismatchNo impedance mismatch No need for primary keysNo need for primary keys One data modelOne data model One programming languageOne programming language No need for query languageNo need for query language High performance for certain tasksHigh performance for certain tasks

Page 52: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Disadvantages of OODBMS

Schema changesSchema changes Lack of agreed standardsLack of agreed standards Lack of ad-hoc queryingLack of ad-hoc querying

In general, RDBMSs are probably more suitable for In general, RDBMSs are probably more suitable for databases with a variety of query and user interface databases with a variety of query and user interface requirements (i.e. most mainstream business requirements (i.e. most mainstream business applications), while OODBMSs are appropriate for applications), while OODBMSs are appropriate for applications with complex, irregular data, where data applications with complex, irregular data, where data access will follow predictable patterns (e.g CAD/CAM access will follow predictable patterns (e.g CAD/CAM systems, manufacturing databases)systems, manufacturing databases)

Page 53: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

OODBMS Users

The Chicago Stock Exchange - managing stock tradesThe Chicago Stock Exchange - managing stock trades CERN in Switzerland - large scientific data setsCERN in Switzerland - large scientific data sets Radio Computing Services – automating radio stations Radio Computing Services – automating radio stations

(library, newsroom, etc)(library, newsroom, etc) Adidas – content for web site and CD-ROM catalogueAdidas – content for web site and CD-ROM catalogue Federal Aviation Authority – passenger and baggage Federal Aviation Authority – passenger and baggage

traffic simulationtraffic simulation Electricite de France – managing overhead power linesElectricite de France – managing overhead power lines

Page 54: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

OODBMS Products

VersantVersant ObjectStore and PSE Pro from eXcelonObjectStore and PSE Pro from eXcelon Objectivity/DBObjectivity/DB Intersystems CacheIntersystems Cache POET fastObjects POET fastObjects db4odb4o Computer Associates JasmineComputer Associates Jasmine GemStoneGemStone

Page 55: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

The Object Relational Model

Page 56: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

The Object Relational Model

The object relational model is an extension of the relational The object relational model is an extension of the relational model, with the following features:model, with the following features: a field may contain an object with attributes and a field may contain an object with attributes and

operations.operations. complex objects can be stored in relational tables complex objects can be stored in relational tables the object relational model offers some of the the object relational model offers some of the

advantages of both the relational and object data modelsadvantages of both the relational and object data models has the commercial advantage of being supported by some has the commercial advantage of being supported by some

of the major RDBMS vendorsof the major RDBMS vendors An object relational DBMS is sometimes referred to as a An object relational DBMS is sometimes referred to as a

hybridhybrid DBMS DBMS

Page 57: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

ORDB Example - OracleCREATE TYPE Name AS OBJECT (

first_name CHAR (15),last_name CHAR (15),middle_initial CHAR (1);MEMBER PROCEDURE initialize,;

Code to define operations – in this case simply a class constructorCREATE TYPE BODY Name AS

MEMBER PROCEDURE initialize ISBEGIN

first_name := NULL;last_name := NULL;middle_initial := NULL;

END initialize;END;

Using the new type in a tableCREATE TABLE person(

person_ID NUMBER;person_name Name,PRIMARY KEY (person_ID));

Page 58: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

OR Mapping Frameworks

Page 59: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

OR Mapping Frameworks

Most databases are relationalMost databases are relational Much effort has been put in recently to Much effort has been put in recently to

making OR mapping more convenientmaking OR mapping more convenient Transparent persistenceTransparent persistence

Page 60: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

OR Mapping Frameworks

Key features:Key features: the programmer can work only with objects – no SQL the programmer can work only with objects – no SQL

statements in the codestatements in the code selected objects are initially marked as being persistent selected objects are initially marked as being persistent

– thereafter, changes in those objects are transparently – thereafter, changes in those objects are transparently changed in the database, and the programmer does not changed in the database, and the programmer does not have to write code specifically to update the databasehave to write code specifically to update the database

the framework handles the mapping of the objects to the framework handles the mapping of the objects to relational database tables where they are actually storedrelational database tables where they are actually stored

mapping of objects to database tables is usually defined mapping of objects to database tables is usually defined in XML descriptor filesin XML descriptor files

Page 61: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

OR Mapping Frameworks

Java Data Objects (JDOJava Data Objects (JDO Applications written to use JDO for persistence can Applications written to use JDO for persistence can

be used with any database for which a JDO be used with any database for which a JDO implementation is available. implementation is available.

Queries are written in a Java-like language JDO Queries are written in a Java-like language JDO Query Language (JDOQL). Query Language (JDOQL).

Mapping of objects to database tables is defined in Mapping of objects to database tables is defined in XML descriptor filesXML descriptor files

Some OODBMS vendors, including POET and Versant Some OODBMS vendors, including POET and Versant have released products which are based on JDO. have released products which are based on JDO.

Page 62: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

OR Mapping Frameworks

Sun’s Enterprise JavaBeans (EJB), an advanced server-Sun’s Enterprise JavaBeans (EJB), an advanced server-side Java component architecture, has its own persistence side Java component architecture, has its own persistence mechanism, mechanism, Container Managed Persistence (CMP) Container Managed Persistence (CMP)

There are also open-source OR mapping frameworks There are also open-source OR mapping frameworks which work in a similar way to JDO, including which work in a similar way to JDO, including HibernateHibernate, , ObJectRelationalBridge (OJB)ObJectRelationalBridge (OJB) and and CastorCastor. .

Commercial products such as Commercial products such as ToplinkToplink make it easier to make it easier to define mappings.define mappings.

Some OR frameworks, including Hibernate and OJB, are Some OR frameworks, including Hibernate and OJB, are compliant with the compliant with the ODMG 3.0 standard ODMG 3.0 standard for interfacing for interfacing with a database.with a database.

Page 63: Object oriented Database Prof. Sin-Min Lee. Database Management Systems Database Models Database Models  Relational Database  Object Oriented Database.

Further Reading