DBMS Lecture 9 Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard OODBMS Object Model Schema OO Data Model Design Notation Oracle implementation of: –Inheritance –Aggregation
Rules that make it an OO system Complex objects must be supported - objects whose data type is more than simply the native data types of number, string, date Object identity – all objects must have a unique identity that is independent of the values of its attributes i.e. objects are not identified by primary key values
Rules that make it an OO system Encapsulation must be supported i.e. access to an object is via its interface [cannot see the internal structure of an object or how its methods work] Object classes the construct of object classes must be supported; the OODBMS schema must comprise a set of classes
Rules that make it an OO system Inheritance of methods and attributes must be supported Dynamic binding the DBMS must bind method names to logic at run time [allows for methods to have the same name but apply to different objects and implement in different ways]
Rules that make it an OO system Complete DML should be a general purpose programming language Extensible set of data types: the user must be able to build new data types from predefined types
Rules that make it an OO system Recovery facilities must be able to recover from hardware and software failure Query management must provide a simple way of querying the data
Rules that make it a DBMS In an OODBMS Data persistence: data must persist after the application has terminated and the user should not need to explicitly initiate persistence. Capable of managing very large databases Concurrent access must be possible
Components of the ODMG [object database management group] standard 1Object Model: a data model to be supported by ODMG compliant DBMS 2Object specification language: Object Definition Language [ODL] ODL used to define objects Object Interchange Format [OIF] OIF used to upload and download object values to secondary storage
Components of the ODMG [object database management group] standard 3Object Query Language: a declarative language for querying the database - based on SQL3 4Language bindings ability to read and write from a database using different programming languages
Features of OODBM models OODBM models real world entities as objects Each object is composed of attributes and a set of methods Each attribute can reference another object or set of objects The attributes and the methods’ implementation are hidden, encapsulated from other objects
Features of OODM models Each object is identified by a unique object id (OID) which is independent of the values of its attributes Similar objects are grouped in a class that contains a description of the attributes and methods The class describes a type of object
Features of OODM models Classes are organized in a class hierarchy Each object in a class inherits all properties of its superclasses in the class hierarchy
Comparing the OO and ER model Components OO data model Type Object Class Instance variable n/a oid method class hierarchy ER data model entity definition entity entity set attribute primary key n/a ER diagram
Object Model: Objects An object – instance of a class –has a unique identity –Property values –may have associated methods Objects are defined against a type hierarchy: –Atomic [e.g. number, string, date] –Collection objects[ e.g. a set of students in a school]
Object Model: Types Class definition defines the abstract behaviour and abstract state of an object type A type has a specification –operations that can be performed –and properties that can be accessed ODMG model includes supertyping and subtyping and the associated notion of inheritance or a generalisation – specialisation relationship
Object Model: Properties Properties may either be an attribute of an object or a relationship between objects. E.G. definition of attributes of a class: Module Attribute string moduleCode; Attribute string moduleName; Attribute short level; Attribute short roll;
Object Model: Properties - relationships E.G. Lecturer teaches Module, Module is taught by Lecturer are the 2 traversal paths for the relationship teaches. E.G. A one to many relationship between a Lecturer type and Module type: CLASS Lecturer { RELATIONSHIP SET Teaches INVERSE Module::TaughtBy; } CLASS Module { RELATIONSHIP Lecturer TaughtBy INVERSE Lecturer::Teaches; }
Object Model: Operations the behaviour of an object is defined by a set of operations [methods] associated with an object. E.G. An operation to increase the roll of a module instance by a set amount VOID increaseRoll (IN SHORT amount);
Object Model: schemas Schemas : –database is defined by a schema specified in the object definition language. schema information defined using ODL is stored in the system catalogue
Example Object Model Schema for an academic Database
OO Data Model Design Notation: Binary Relationships
OO Data model Design Notation: Inheritance
OO Data Model Design Notation: Aggregation
OO Data Model Design Notation: Reference
Implementing Inheritance in Oracle NOT INSTANTIATED
Storing Objects in tables Either a super type table or series of sub type tables CREATE TABLE persons OF person_typ (CONSTRAINT persons_pk PRIMARY KEY (id));
Inserting data INSERT INTO persons VALUES(NEW employee1_typ(001, ‘bloggs’,’12-jun-2006’,12000,3000)); INSERT INTO persons VALUES(NEW student1_typ(001, ‘jones’,’12- jul-2006’,65));
Retrieving objects from object tables: SELECT VALUE (p) FROM persons p;
Example: Implementing Aggregation & Referencing in Oracle
Implementing Aggregation & Referencing in Oracle
workshop Implementing an OO data model using SQL3 OO extension –Creating Object types –Creating tables for object types –Inserting data –Retrieving data