Professional Documents
Culture Documents
Outline
Object-Oriented Data Model Object-Oriented Database System(OODBS) Object-Oriented Data Definition Language Object-Oriented Query Language Index organizations for OODBS Query Optimization in OODBS
Definition of an object
Objects User defined complex data types
An object has structure or state (variables) and methods (behavior/operations)
Object Identity
unique identity for each independent object stored in the database created by a unique, system-generated object identifier, or OID
Object Identity
properties of OID
immutable: the OID value of a particular object should not change
OID should not depend on any physical address attribute values of the object
Object Structure
The state (current value) of a complex object may be constructed from other objects (or other values) by using certain type constructors Can be represented by (i,c,v)
Basic types: atom (integer,real,string,Boolean,) Structured type: tuple Collection type: array vs. list (order), set vs. bag (unorder)
Object Structure
Object states
c=atom ::: an atomic value from the domain c=set ::: a set of object identifiers {i1, i2, , in} c=tuple ::: a tuple of <a1:i1, a2:i2, , an:in> c=list ::: an ordered list [i1, i2, , in] c=array ::: a single-dimensional array of object identifiers c=bag
Object-Oriented Concepts
Class definition provides extension to complex attribute types Implementation of operations and object structure hidden Sharing of data within hierarchy scope, supports code reusability Operator overloading
Encapsulation
Inheritance
Polymorphism
LEGEND:
NAME
NUMBER MANAGER
LOCATIONS
i5: O5 atom
V5
i 7: O 7 set V7
Research
V9 O1 V1
O2 V2
Class Schema
Outline
Object-Oriented Data Model Object-Oriented Database System(OODBS) Object-Oriented Data Definition Language Object-Oriented Query Language Index organizations for OODBS Query Optimization in OODBS
Advantages of OODBS
Designer can specify the structure of objects and their behavior (methods) Better interaction with object-oriented languages such as Java and C++ Definition of complex and user-defined types Encapsulation of operations and userdefined methods
Outline
Object-Oriented Data Model Object-Oriented Database System(OODBS) Object-Oriented Data Definition Language Object-Oriented Query Language Index organizations for OODBS Query Optimization in OODBS
integer; integer; integer; ); string; integer; tuple (manager: Employee; startdate: Date; ); set (string); set (Employee); set (Project); );
set of references
define type Department tuple ( name: number: manager: locations: members: control:
Define the behavior of a type of object based on the operations that can be externally applied to object of that type
create (insert) or destroy (delete) objects update the object state retrieve parts of the object state apply some calculations combination of retrieval, calculation, and update
type definition
definition of operations
type definition
Employee; Date; );
definition of operations
operations number_of_emps : integer; create_dept: Department, destroy_dept: boolean; assign_emp (e: Employee): boolean; (* adds a new employee to the department *) remove_emp (e: Employee): boolean; (* removes an employee from the department *) end Department;
Class Operations
object constructor create a new object destructor destroy an object object modifier modify various attribute of an object dot notation d.no_of_emps where d is a reference to a department object and no_of_emps is an operation
refer to attributes of an object: d.dnumber, d.mgr.startdate
persistent object
stored in the database and persist after program termination
naming mechanism
give an object a unique persistent name through which it can be retrieved by this and other program
Reachability
reachability mechanism
make the object reachable from some persistent object an object B is said to be reachable from an object A if a sequence of references in the object graph lead from object A to object B e.g., if o8 is persistent, then all other objects also become persistent (next slide) N defines a persistent collection of objects of class C create a named persistent object N, whose state is a set or list of objects of some class C add objects of C to the set or list and make them reachable from N
LEGEND:
NAME
NUMBER MANAGER
LOCATIONS
i5: O5 atom
V5
i 7: O 7 set V7
Research
V9 O1 V1
O2 V2
persistent name AllDepartments: DepartmentSet ; (* AllDepartments is a persistent named object of type set DepartmentSet*)
.....
d := create_dept ; ..... (* creates a new department object in the variable d *) b := AllDepartments.add_dept (d) ; (* make d persistent by adding it to the persistent named object AllDepartments *) AllDepartments object: extent of the class Department
OO approaches
a class declaration specifies only the type and operations for a class of objects user must define a persistent object whose value is the collection of references to all persistent
10
TYPE_NAME: function, function, , function PERSON: Name, Address, Birthdate, Age, SSN EMPLOYEE subtype-of PERSON: Salary, HireDate, Seniority STUDENT subtype-of PERSON: Major, GPA
Inheritance
multiple inheritance
when T is a subtype of two (or more) types, T inherits the functions (attributes and methods) of both supertypes type lattice instead of type hierarchy if a function is inherited from some common supertype, it is inherited only once ambiguity resolution alarm users system default disallow multiple inheritance
Inheritance (Continued)
Selective Inheritance
a subtype inherits only some of the functions of a supertype an EXCEPT clause may be used to list the functions in a super type that are not to be inherited by the subtype
11
Outline
Object-Oriented Data Model Object-Oriented Database System(OODBS) Object-Oriented Data Definition Language Object-Oriented Query Language Index organizations for OODBS Query Optimization in OODBS
Syntax based on SQL (select, from, where) Additional flexibility (queries with user defined operators and types)
12
- The statement queries a relational database. => Returns a table with rows.
13
Comparison
Queries look very similar in SQL and OQL, sometimes they are the same In fact, the results they give are very different Query returns: OQL
Object Collection of objects
SQL
Tuple Table
Outline
Object-Oriented Data Model Object-Oriented Database System(OODBS) Object-Oriented Data Definition Language Object-Oriented Query Language Index organizations for OODBS Query Optimization in OODBS
14
15
Outline
Object-Oriented Data Model Object-Oriented Database System(OODBS) Object-Oriented Data Definition Language Object-Oriented Query Language Index organizations for OODBS Query Optimization in OODBS
16
Object algebra
17
18
19
20
21
22
23
Cost Estimation
Method Materialisation
A method materialisation consists:
compute the result of a method once, store the method's result persistently in a database, use the persistent result value when the method is invoked. maintain the materialised results: update the values of materialised methods when objects used for computing them change (base objects)
Method Materialisation
reduce applications response time for accessing a method's result, especially when its execution takes long time. add methods maintenance cost
in order to improve a system's performance, only the right set of methods should be materialised method materialisation (precomputation, caching) was proposed in the context of indexing techniques and query optimisation.
24
Method Materialisation
Two important issues arise for method materialisation :
(1) what technique to use for method materialisation, and (2) which methods to materialise?
Method Materialisation
Storage Structures
Materialised Methods Dictionary (MMD) contains information about all methods:
a method name and class, the array of input arguments, a method return type, a method implementation, and a flag indicating if a method was materialised.
Method Materialisation
Storage Structures
Materialised Method Results Structure (MMRS) stores the following information about every materialised method:
(1) the identifier of a method, (2) an object identifier the method was invoked for, (3) the array of input argument values a method was invoked with, (4) the value returned by a method while executed for a given object and for a given array of input argument values.
When materialised method mi is required, then MMRS is searched in order to get the result of mi. If it is not found then, the value of mi is computed and stored in MMRS. When an object used to compute the materialised value of mi is updated or deleted, then the materialised value becomes invalid and is removed from MMRS.
25
Method Materialisation
Storage Structures
GMC stores pairs of values:
the identifier of a calling method and the identifier of a method being called.
Graph of Method Calls (GMC) represent dependencies between methods, where one calls another one. GMC is used by the procedure that maintains the materialised results of methods.
Method Materialisation
Storage Structures
In order to invalidate dependent methods the system must be able to find also inverse references in object composition hierarchy. The references are maintained in a data structure called Inverse References Index (IRI).
Method Materialisation
Storage Structures
Method Value Index (MVI) is an index defined on results of methods. Every method of a class has its own MVI. The index stores the following:
(1) the value of a method input argument, (2) a method result, and (3) an object identifier a method was invoked for.
By using this index, the system is able to quickly find answers to queries that use methods. The content of MVI is filled in with data when methods are materialised.
26
Step 2:
identify methods whose materialisation increases system's performance dematerialise automatically methods whose materialisation deteriorates the system's performance
27
represents a coefficient by which an overall system's response time is to be reduced. It takes its value from the range of (0, 1) and it is considered as a tuning parameter set up by an administrator.
28
for a given method mi and a given batch transaction set, if the inequality in formula 3 is true, then mis materialisation increase system's performance. Otherwise, mi has to be dematerialised.
Disadvantages
There is no underlying theory to match the relational model Can be more complex and less efficient OODB queries tend to be procedural, unlike SQL
29