33
DBMS DBMS Lecture 9 Lecture 9 Object Database Management Group Object Database Management Group 12 Rules for an OODBMS 12 Rules for an OODBMS Components of the ODMG standard Components of the ODMG standard OODBMS Object Model Schema OODBMS Object Model Schema OO Data Model Design Notation OO Data Model Design Notation Oracle implementation of: Oracle implementation of: Inheritance Inheritance Aggregation Aggregation

DBMS Lecture 9 Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard OODBMS Object Model Schema OO Data Model

Embed Size (px)

Citation preview

Page 1: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

DBMSDBMSLecture 9Lecture 9

Object Database Management GroupObject Database Management Group– 12 Rules for an OODBMS12 Rules for an OODBMS– Components of the ODMG standardComponents of the ODMG standard

OODBMS Object Model SchemaOODBMS Object Model Schema

OO Data Model Design NotationOO Data Model Design Notation

Oracle implementation of:Oracle implementation of:– InheritanceInheritance– AggregationAggregation

Page 2: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Rules that make it an OO systemRules that make it an OO system

Complex objects must be supported - Complex objects must be supported - objects whose data type is more than simply objects whose data type is more than simply the native data types of number, string, datethe native data types of number, string, date

Object identity – all objects must have a Object identity – all objects must have a unique identity that is independent of the unique identity that is independent of the values of its attributes i.e. objects are not values of its attributes i.e. objects are not identified by primary key valuesidentified by primary key values

Page 3: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Rules that make it an OO systemRules that make it an OO system

Encapsulation must be supported i.e. Encapsulation must be supported i.e. access to an object is via its interface access to an object is via its interface [cannot see the internal structure of an [cannot see the internal structure of an object or how its methods work]object or how its methods work]

Object classes the construct of object Object classes the construct of object classes must be supported; the OODBMS classes must be supported; the OODBMS schema must comprise a set of classesschema must comprise a set of classes

Page 4: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Rules that make it an OO systemRules that make it an OO system

Inheritance of methods and attributes must Inheritance of methods and attributes must be supportedbe supported

Dynamic binding the DBMS must bind Dynamic binding the DBMS must bind method names to logic at run time [allows method names to logic at run time [allows for methods to have the same name but for methods to have the same name but apply to different objects and implement in apply to different objects and implement in different ways]different ways]

Page 5: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Rules that make it an OO systemRules that make it an OO system

Complete DML should be a general purpose Complete DML should be a general purpose programming languageprogramming language

Extensible set of data types: the user must Extensible set of data types: the user must be able to build new data types from be able to build new data types from predefined typespredefined types

Page 6: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Rules that make it an OO systemRules that make it an OO system

Recovery facilities must be able to recover Recovery facilities must be able to recover from hardware and software failurefrom hardware and software failure

Query management must provide a simple Query management must provide a simple way of querying the dataway of querying the data

Page 7: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Rules that make it a DBMSRules that make it a DBMS In an OODBMSIn an OODBMS

Data persistence: data must persist after the Data persistence: data must persist after the application has terminated and the user application has terminated and the user should not need to explicitly initiate should not need to explicitly initiate persistence.persistence.

Capable of managing very large databasesCapable of managing very large databases Concurrent access must be possibleConcurrent access must be possible

Page 8: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Components of the ODMGComponents of the ODMG [object database management group] standard [object database management group] standard

11 Object ModelObject Model: a data model to be : a data model to be supported by ODMG compliant DBMSsupported by ODMG compliant DBMS

22 Object specification language:Object specification language: Object Definition Language [ODL] ODL used to Object Definition Language [ODL] ODL used to

define objectsdefine objects Object Interchange Format [OIF] OIF used to Object Interchange Format [OIF] OIF used to

upload and download object values to upload and download object values to secondary storagesecondary storage

Page 9: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Components of the ODMG [object database Components of the ODMG [object database management group] standardmanagement group] standard

33 Object Query Language:Object Query Language: a declarative a declarative language for querying the database - based language for querying the database - based on SQL3on SQL3

44 Language bindingsLanguage bindings ability to read and write ability to read and write from a database using different from a database using different programming languagesprogramming languages

Page 10: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Features of OODBM modelsFeatures of OODBM models

OODBM models real world entities as OODBM models real world entities as objectsobjects

Each object is composed of attributes and a Each object is composed of attributes and a set of methodsset of methods

Each attribute can reference another object Each attribute can reference another object or set of objectsor set of objects

The attributes and the methods’ The attributes and the methods’ implementation are hidden, encapsulated implementation are hidden, encapsulated from other objectsfrom other objects

Page 11: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Features of OODM modelsFeatures of OODM models

Each object is identified by a unique object Each object is identified by a unique object id (OID) which is independent of the values id (OID) which is independent of the values of its attributesof its attributes

Similar objects are grouped in a class that Similar objects are grouped in a class that contains a description of the attributes and contains a description of the attributes and methodsmethods

The class describes a type of objectThe class describes a type of object

Page 12: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Features of OODM modelsFeatures of OODM models

Classes are organized in a class hierarchyClasses are organized in a class hierarchy Each object in a class inherits all properties Each object in a class inherits all properties

of its superclasses in the class hierarchyof its superclasses in the class hierarchy

Page 13: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Comparing the OO and ER model ComponentsComparing the OO and ER model Components

OO data modelOO data model TypeType ObjectObject ClassClass Instance variableInstance variable n/an/a oidoid methodmethod class hierarchyclass hierarchy

ER data modelER data model entity definitionentity definition entityentity entity setentity set attributeattribute primary keyprimary key n/an/a n/an/a ER diagramER diagram

Page 14: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Object Model:Object Model:Objects Objects

An objectAn object– instance of a classinstance of a class– has a unique identity has a unique identity – Property valuesProperty values– may have associated methodsmay have associated methods

Objects are defined against a type hierarchy:Objects are defined against a type hierarchy:– Atomic [e.g. number, string, date]Atomic [e.g. number, string, date]– Collection objects[ e.g. a set of students in a school]Collection objects[ e.g. a set of students in a school]

Page 15: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Object Model:Object Model:TypesTypes

Class definition defines the abstract behaviour and abstract Class definition defines the abstract behaviour and abstract state of an object type state of an object type

A type has a specification A type has a specification – operations that can be performed operations that can be performed – and properties that can be accessed and properties that can be accessed

ODMG model includes supertyping and subtyping and the ODMG model includes supertyping and subtyping and the associated notion of inheritance or a generalisation – associated notion of inheritance or a generalisation – specialisation relationshipspecialisation relationship

Page 16: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Object Model:Object Model:PropertiesProperties

Properties may either be an attribute of an object Properties may either be an attribute of an object or a relationship between objects.or a relationship between objects.

E.G. definition of attributes of a class: E.G. definition of attributes of a class: ModuleModule

Attribute string Attribute string moduleCodemoduleCode;;

Attribute stringAttribute string moduleName; moduleName;

Attribute shortAttribute short level; level;

Attribute shortAttribute short roll; roll;

Page 17: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Object Model:Object Model:Properties - relationshipsProperties - relationships

E.G. E.G. LecturerLecturer teaches teaches ModuleModule, , ModuleModule is taught by is taught by Lecturer Lecturer are the 2 are the 2 traversal paths for the relationship traversal paths for the relationship teaches.teaches.

E.G. A one to many relationship between a Lecturer type and Module E.G. A one to many relationship between a Lecturer type and Module type:type:CLASS LecturerCLASS Lecturer{{

RELATIONSHIP SET<module> Teaches INVERSE RELATIONSHIP SET<module> Teaches INVERSE Module::TaughtBy;Module::TaughtBy;}}CLASS ModuleCLASS Module{{RELATIONSHIP Lecturer TaughtBy INVERSE Lecturer::Teaches;RELATIONSHIP Lecturer TaughtBy INVERSE Lecturer::Teaches;}}

Page 18: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Object Model:Object Model:OperationsOperations

the behaviour of an object is defined by a set of operations the behaviour of an object is defined by a set of operations [methods] associated with an object.[methods] associated with an object.

E.G. An operation to increase the roll of a module E.G. An operation to increase the roll of a module instance by a set amountinstance by a set amount

VOID increaseRoll (IN SHORT amount);VOID increaseRoll (IN SHORT amount);

Page 19: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Object Model:Object Model:schemasschemas

Schemas :Schemas :– database is defined by a schema specified in the object database is defined by a schema specified in the object

definition language.definition language.

schema information defined using ODL is stored in schema information defined using ODL is stored in

the system catalogue the system catalogue

Page 20: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Example Object Model Schema for an academic Database

Page 21: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Example Object Model Schema for an academic Database

Page 22: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Example Object Model Schema for an academic Database

Page 23: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

OO Data Model Design Notation:OO Data Model Design Notation:Binary RelationshipsBinary Relationships

Page 24: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

OO Data model Design Notation:OO Data model Design Notation:InheritanceInheritance

Page 25: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

OO Data Model Design Notation:OO Data Model Design Notation:AggregationAggregation

Page 26: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

OO Data Model Design Notation:OO Data Model Design Notation:ReferenceReference

Page 27: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Implementing Inheritance in OracleImplementing Inheritance in Oracle NOT INSTANTIATED

Page 28: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Storing Objects in tablesStoring Objects in tables

Either a super type table or series of sub Either a super type table or series of sub type tablestype tables

CREATE TABLE persons OF person_typCREATE TABLE persons OF person_typ

(CONSTRAINT persons_pk PRIMARY KEY (CONSTRAINT persons_pk PRIMARY KEY (id));(id));

Page 29: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Inserting dataInserting data

INSERT INTO personsINSERT INTO persons

VALUES(NEW employee1_typ(001, VALUES(NEW employee1_typ(001, ‘bloggs’,’12-jun-2006’,12000,3000));‘bloggs’,’12-jun-2006’,12000,3000));

INSERT INTO personsINSERT INTO persons

VALUES(NEW student1_typ(001, ‘jones’,’12-VALUES(NEW student1_typ(001, ‘jones’,’12-jul-2006’,65));jul-2006’,65));

Page 30: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Retrieving objects from object tables:Retrieving objects from object tables:

SELECT VALUE (p)SELECT VALUE (p)

FROM persons p;FROM persons p;

Page 31: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Example: Implementing Aggregation & Referencing in Oracle

Page 32: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

Implementing Aggregation & Referencing in Oracle

Page 33: DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model

workshopworkshop

Implementing an OO data model using Implementing an OO data model using SQL3 OO extensionSQL3 OO extension– Creating Object typesCreating Object types– Creating tables for object typesCreating tables for object types– Inserting dataInserting data– Retrieving dataRetrieving data