Object-Oriented Database Systems - IfI
Object-Oriented Database Systems - IfI
Object-Oriented Database Systems - IfI
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Object</strong>-<strong>Oriented</strong> <strong>Database</strong> <strong>Systems</strong><br />
Standardization Efforts<br />
18.09.2002 INF 312, Ifi, UiO 1<br />
<strong>Object</strong>-<strong>Oriented</strong> DBS vs. <strong>Object</strong>-Relational DBS<br />
two ways to integrate object-orientation into DBS<br />
-> both directions are also reflected in standards developments<br />
commercial OODBS (examples): commercial ORDBS (examples):<br />
- GemStone (Brokat Infosys AG) - ORACLE<br />
- O2 (Ardent -> Informix) - Sybase<br />
- <strong>Object</strong>ivityDB - Informix (Illustra)<br />
- <strong>Object</strong>Store (ODI -> eXcelon) - IBM<br />
- POET - CinCom (UNISQL, Total)<br />
- Versant - Microsoft<br />
- Jasmine (Computer Associates) - ...<br />
- ...<br />
18.09.2002 INF 312, Ifi, UiO 3<br />
<strong>Object</strong> Data System Vendors<br />
• <strong>Object</strong>-<strong>Oriented</strong><br />
• <strong>Object</strong>-Relational<br />
Overview<br />
<strong>Object</strong>-<strong>Oriented</strong> DBS (OODBS) standards<br />
• OMG: <strong>Object</strong> Model, OMA -> CORBA, POA, PSS<br />
• ODMG 3.0 version<br />
18.09.2002 INF 312, Ifi, UiO 2<br />
<strong>Object</strong>-<strong>Oriented</strong> DBS vs <strong>Object</strong>-Relational DBS<br />
OODBS ORDBS<br />
• simpler way for programmer to use<br />
DBS (familiar with OOPLs)<br />
• “seamlessness”, no “impedance<br />
mismatch”<br />
• OO functionality + DBS functionality<br />
=> higher performance for specific<br />
applications<br />
• “revolutionary” approach, no legacy<br />
problems<br />
• substantial investment in<br />
SQL-based relational DBSs<br />
=> evolutionary approach<br />
• systems are more robust due<br />
to many years of usage and<br />
experience<br />
• application development tools<br />
• data security<br />
• transaction processing<br />
performance<br />
• day-to-day business<br />
requirements, e.g., online<br />
backup<br />
predictions:<br />
- both kinds of systems will exist, used for different kinds of applications<br />
18.09.2002 INF 312, Ifi, UiO 4
<strong>Object</strong>-<strong>Oriented</strong> DBS vs. <strong>Object</strong>-Relational DBS<br />
Michael Stonebraker’s Application Matrix:<br />
• Classify your problem into one of the four quadrants<br />
• Use a DBMS optimized for the quadrant<br />
Query<br />
No Query<br />
Relational DBMS<br />
File System<br />
<strong>Object</strong>-Relational DBMS<br />
<strong>Object</strong>-<strong>Oriented</strong> DBMS<br />
Simple Data Complex Data<br />
How large is the upper-right corner?<br />
• ”Many applications will migrate from the upper-left”<br />
• ”It is growing and it will engulf upper-left and lower-right”<br />
18.09.2002 INF 312, Ifi, UiO 5<br />
<strong>Object</strong> Management Group (OMG)<br />
International software industry consortium (started 1989)<br />
today: 800+ companies<br />
Original members:<br />
• 3COM<br />
• American Airlines<br />
• Hewlett-Packard Co. (HP, Palo Alto, CA)<br />
• Sun Microsystems Inc. (Mountain View, CA)<br />
Examples of other members (vendors and end-users):<br />
Informix Software Inc., Apple Computer, Philips, Olivetti, IBM,<br />
AT&T, Groupe Bull, ICL, Enfin <strong>Systems</strong>, Canon, Unisys,<br />
Architecture Project Management, British Telecom, Citicorp,<br />
Royal Bank of Canada, John Deere, Microsoft, etc.<br />
18.09.2002 INF 312, Ifi, UiO 7<br />
<strong>Object</strong> Data System Vendors<br />
• <strong>Object</strong>-<strong>Oriented</strong><br />
• <strong>Object</strong>-Relational<br />
Overview<br />
<strong>Object</strong>-<strong>Oriented</strong> DBS (OODBS) standards<br />
• OMG: <strong>Object</strong> Model, OMA -> CORBA, POA, PSS<br />
• ODMG 3.0 version<br />
18.09.2002 INF 312, Ifi, UiO 6<br />
OMG Focus<br />
Common Goal: Create a component-based software marketplace<br />
by hastening the introduction of standardized object software.<br />
Establish industry guidelines and detailed object management<br />
specifications to provide a common framework for application<br />
development.<br />
• IDL (Interface Definition Language)<br />
• OMA (<strong>Object</strong> Management Architecture)<br />
• CORBA (Common <strong>Object</strong> Request Broker Architecture)<br />
– CORBA 1: 1991<br />
– CORBA 3: 2000<br />
• CORBA Facilities and CORBA Services<br />
18.09.2002 INF 312, Ifi, UiO 8
OMG Technology<br />
Platform Technology<br />
• Analysis and Design<br />
– UML (Unified Modeling Language)<br />
– XMI (XML Metadata Interchange)<br />
– MOF (Meta-<strong>Object</strong> Facility)<br />
• Real-Time CORBA<br />
• ORB (<strong>Object</strong> Request Broker)<br />
Domain Technology<br />
• 23 Domain Task Forces<br />
– Business <strong>Object</strong>s, C4I, e-Commerce, Finance, Healthcare,<br />
Life Science, Manufacturing, Telecommunications, etc.<br />
Architecture Board<br />
• OMA (<strong>Object</strong> Management Architecture and Reference Model)<br />
18.09.2002 INF 312, Ifi, UiO 9<br />
OMA (<strong>Object</strong> Management Architecture)<br />
• OMA specifies the overall object model that is used in<br />
distributed object computing environments, including<br />
– how objects are defined and created,<br />
– how client applications invoke objects,<br />
– how objects can be shared.<br />
• OMA sets the component software environment<br />
– how components provide services<br />
– how facilities provide services<br />
– how CORBA services provide services<br />
• Facilitated by the ORB (<strong>Object</strong> Request Broker)<br />
18.09.2002 INF 312, Ifi, UiO 11<br />
OMG Current Efforts<br />
• Business <strong>Object</strong> Initiative<br />
• CWM (Common Warehouse Model)<br />
• CCM (CORBA Component Model)<br />
• Java and Internet integration<br />
• MOF (Meta <strong>Object</strong> Facility)<br />
• PSS (Persistent State Service)<br />
• Quality of Service Control<br />
• Real Time CORBA<br />
• UML (Unified Modeling Language)<br />
• Workflow Management<br />
• XMI (XML Metadata Interchange)<br />
• etc.<br />
18.09.2002 INF 312, Ifi, UiO 10<br />
Application objects:<br />
• Spreadsheet<br />
• CAD tool<br />
• Accounting<br />
•Editors<br />
•….<br />
Application<br />
<strong>Object</strong>s<br />
OMA Reference Model<br />
Horizontal facilities:<br />
• Internationalization<br />
• MOF<br />
•….<br />
Horizontal<br />
Facilities<br />
Vertical<br />
Facilities<br />
Vertical facilities:<br />
• Healthcare<br />
• e-Commerce<br />
•….<br />
<strong>Object</strong> Request Broker (ORB)<br />
EJB<br />
Component<br />
EJB<br />
Container<br />
Components:<br />
• Account Receivable<br />
• Account Payable<br />
• Ledger<br />
•….<br />
CCM<br />
Component<br />
CCM<br />
Container<br />
ORB:<br />
• Name service<br />
• Request dispatch<br />
• Parameter encoding<br />
•…<br />
CORBA <strong>Object</strong> Services<br />
<strong>Object</strong> Services:<br />
•Naming<br />
• Transaction<br />
• Persistent State<br />
• Security<br />
• Query<br />
18.09.2002 INF 312, Ifi, UiO<br />
•…<br />
12
OMG: CORBA <strong>Object</strong> Model<br />
CORBA includes an object model of types, operations, and subtyping.<br />
In the object model, the user can manipulate instances but not types or<br />
operations as first-class objects.<br />
- basic concepts<br />
- object identity and object identifiers<br />
- object types<br />
- value types<br />
- operations<br />
- subtyping and inheritance<br />
- argument passing and results<br />
- interfaces of a type<br />
- implementation<br />
18.09.2002 INF 312, Ifi, UiO 13<br />
OMG: <strong>Object</strong> Identiy & <strong>Object</strong> Identifiers<br />
Each object has a unique identity (object identifier, OID) that is distinct<br />
from and independent of any of its characteristics.<br />
OID provides a means to denote or refer to the object.<br />
Characteristics can vary over time, whereas identity (OID) is constant.<br />
Implementation of OIDs is not specified.<br />
18.09.2002 INF 312, Ifi, UiO 15<br />
OMG <strong>Object</strong> Model - Basic Concepts<br />
Client: An object system provides services to clients. A client of a service<br />
is any entity capable of requesting the service..<br />
<strong>Object</strong>: An object is an identifiable, encapsulated entity that provides one<br />
or more services that can be requested by a client.<br />
Type: A type is an identifiable entity with an associated predicate (a<br />
single-argument mathematical function with a boolean result) defined over<br />
entities. An entity that satisfies a type is called a member of the type.<br />
Interface: An interface is a description of a set of possible operations that<br />
a client may request of an object, through that interface.<br />
Operation: An operation is an identifiable entity that denotes the<br />
indivisible primitive of service provision that can be requested..<br />
Attribute: An interface may have attributes. An attribute is logically equivalent to<br />
a pair of accessor functions: one to retrieve the value and one to set the value.<br />
18.09.2002 INF 312, Ifi, UiO 14<br />
OMG: <strong>Object</strong> Types<br />
<strong>Object</strong>s support only certain operations.<br />
Operations applicable to an object characterize its behavior.<br />
Types describe these operations and thus characterize the behavior of<br />
objects.<br />
<strong>Object</strong>s are created as instances of their types. <strong>Object</strong>s cannot change<br />
their types.<br />
Each operation has a signature, which consists of a name, set of<br />
parameters, and set of results.<br />
The set of operation signatures defined on a type is called the type´s<br />
interface.<br />
Every instance of a type satisfies the interface of that type.<br />
Types are arranged into a type hierarchy that forms a directed acyclic<br />
graph.<br />
18.09.2002 INF 312, Ifi, UiO 16
OMG: Value Types<br />
A value type is an entity which shares many of the<br />
characteristics of interfaces and structs. It is a description of<br />
both a set of operations that a client may request and of state<br />
that is accessible to a client. Instances of a value type are<br />
always local concrete implementations in some programming<br />
language.<br />
<strong>Object</strong>s + Value Types = Set of Denotable Values<br />
Value Types provide ”pass by value” semantics<br />
Basic values include Short, Long, LongLong, Ushort, Ulong,<br />
UlongLong, Float, Double, LongDouble, Fixed, Char, Wchar,<br />
String, Wstring, Boolean, Octet, Enum, Any<br />
18.09.2002 INF 312, Ifi, UiO 17<br />
OMG: Request in OMA<br />
Client <strong>Object</strong> implementation<br />
ORB<br />
Request<br />
A request consists of:<br />
• target object<br />
• operation<br />
• parameters<br />
• optional request context<br />
18.09.2002 INF 312, Ifi, UiO 19<br />
OMG: Operations<br />
Operation (definition of signature) describes an action that can be<br />
applied to parameters.<br />
Operation Invocation = Request: is an event that indicates an operation<br />
and possibly parameter lists some on behalf of a requester (client),<br />
possibly causing results to be returned.<br />
Request and operations are not objects.<br />
Each operation has a signature consisting of:<br />
-name<br />
- set of parameters<br />
- the result<br />
- exceptions that may be raised by an invocation<br />
Set of operation signatures defined on a type is called the type´s interface.<br />
18.09.2002 INF 312, Ifi, UiO 18<br />
OMG: Subtyping and Inheritance<br />
Subtyping (specialization) is a relationship between types based on their<br />
interfaces.<br />
Subtyping defines the rules which objects of one type are determined to be<br />
acceptable in contexts expecting another type.<br />
Relationships between types define the type hierarchy (directed acyclic graph)<br />
Inheritance is a mechanism for reuse.<br />
Inheritance allows a type to be defined in terms of another type.<br />
Operation dispatching: when an operation request is issued, a specific<br />
operation implementation (method) is selected for execution.<br />
18.09.2002 INF 312, Ifi, UiO 20
OMG: Argument Passing and Results<br />
Execution semantics consist of arguments and return values to<br />
formal parameters.<br />
-> check: is request legal?<br />
Expressions result in Value Types or OIDs (denotable values).<br />
Operationally, the denotable values are copied into the formal<br />
parameters. The objects the OIDs refer to are not copied.<br />
If an operation request returns successfully, it was performed<br />
exactly once; if it returns an exception indication, it was<br />
performed at-most-once.<br />
18.09.2002 INF 312, Ifi, UiO 21<br />
OMG: Implementation<br />
The object model formally specifies only the semantics of objects,<br />
nothing about implementation.<br />
The combination of a type specification and one of the<br />
implementations defined for that type is called class.<br />
An individual object, at any given point in time, is an instance of<br />
one class.<br />
Implementations may vary among different instances of a type<br />
and even for the same instance over time.<br />
18.09.2002 INF 312, Ifi, UiO 23<br />
OMG: Interfaces of a Type<br />
A type exports all the operations that are defined on it.<br />
An interface is a description of a set of possible operations<br />
that a client may request of an object, through that interface.<br />
It provides a syntactic description of how a service provided<br />
by an object supporting this interface, is accessed via the set<br />
of operations of the object’s type.<br />
Interface inheritance provides the composition mechanism<br />
for permitting an object to support multiple interfaces.<br />
18.09.2002 INF 312, Ifi, UiO 22<br />
OMG: CORBA<br />
Standard that defines specific ways for objects and clients<br />
within a distributed environment to interact.<br />
The basis distributed object computing components<br />
defined in CORBA include:<br />
- Static and Dynamic Invocation Interfaces (SII, DII)<br />
- Interface Definition Language (IDL)<br />
- C Language Mapping<br />
- Interface Repository (IR)<br />
- ORB Interface and Server Implementation<br />
- Basic and Portable <strong>Object</strong> Adapter Interfaces<br />
18.09.2002 INF 312, Ifi, UiO 24
OMG: CORBA – Remote Procedure Calls<br />
Caller<br />
Callee<br />
before after<br />
Interface<br />
description<br />
Compiler<br />
Caller<br />
Stub<br />
Skeleton<br />
Callee<br />
Network<br />
interface<br />
18.09.2002 INF 312, Ifi, UiO 25<br />
Client<br />
OMG: Inter-ORB Interoperability<br />
ORB1<br />
Request<br />
<strong>Object</strong> implementation<br />
ORB2<br />
Basic <strong>Object</strong> Adapter may be used in same ORB<br />
Portable <strong>Object</strong> Adapter used across ORBs<br />
<strong>Object</strong> implementation<br />
IIOP (Internet Inter-ORB Protocol) hides differences in<br />
platform and software (programming language, OS, ORB)<br />
18.09.2002 INF 312, Ifi, UiO 27<br />
Dynamic<br />
invoke<br />
OMG: CORBA Internal Architecture<br />
Client<br />
Client<br />
stubs<br />
1 interface<br />
1 interface/adaptor<br />
1 interface/operation<br />
ORB<br />
interface<br />
ORB core<br />
<strong>Object</strong><br />
implementation<br />
Implement.<br />
Skeletons<br />
<strong>Object</strong><br />
adapter<br />
Proprietary interface<br />
Normal call interface<br />
Upcall interface<br />
18.09.2002 INF 312, Ifi, UiO 26<br />
Interface<br />
repository<br />
Interface<br />
definitions<br />
OMG: CORBA - Interfaces<br />
Client<br />
stubs<br />
Implementation<br />
installation<br />
Implement.<br />
skeletons<br />
Accesses Includes Includes<br />
Describes<br />
Implement.<br />
repository<br />
Client <strong>Object</strong> implementation<br />
18.09.2002 INF 312, Ifi, UiO 28
OMG: CORBA - Types and <strong>Object</strong> Interfaces<br />
Type in general refers to things that may be specified as<br />
arguments or results in the signatures of operations.<br />
<strong>Object</strong> Interfaces (IDL)<br />
IDL Data Types: - basic types: -- integer types<br />
-- floating point types<br />
-- char, boolean, octet<br />
- constructed types (struct, union, enum)<br />
- template types (sequence, string)<br />
- array<br />
Pseudo-<strong>Object</strong>s: requests, named-value lists, contexts, interface<br />
definition objects, implementation definition objects<br />
18.09.2002 INF 312, Ifi, UiO 29<br />
OMG: CORBA <strong>Object</strong> Services<br />
• Naming Service<br />
• Trader Service<br />
• Event Service<br />
• Notification Service<br />
• Transaction Service<br />
• Concurrency Service<br />
• Security Service<br />
• icensing Service<br />
• Lifecycle Service<br />
• Relationship Service<br />
• Persistent State Service<br />
• Externalization Service<br />
• Property Service<br />
• Query Service<br />
• Time Service<br />
18.09.2002 INF 312, Ifi, UiO 31<br />
OMG: CORBA - Operations and Requests<br />
A client performs a request by having access to an object<br />
reference for an object and knowing the immediate type of the<br />
object and the desired operation to be performed.<br />
A client initiates a request by calling a stub routine specific to the<br />
object type or by constructing the request dynamically via the DII<br />
(Dynamic Invocation Interface).<br />
Features of operations that can be specified in IDL:<br />
- invocation semantics<br />
- parameter directions<br />
- exceptions raised<br />
- context<br />
18.09.2002 INF 312, Ifi, UiO 30<br />
OMG: Horizontal (Common) Facilities<br />
• User Interface Common Facilities<br />
– Internationalization<br />
– Printing<br />
• Information Management Common Facilities<br />
– Meta <strong>Object</strong> Facility<br />
• System Management Common Facilities<br />
– XCMF (superceded by CCM)<br />
• Task Management Common Facilities<br />
– Workflow Facility (with Workflow Management Coalition)<br />
Services have now much higher priority than common facilities.<br />
18.09.2002 INF 312, Ifi, UiO 32
OMG: Vertical (Domain) Facilities<br />
• Business <strong>Object</strong> Facilities<br />
– Task and Session<br />
– Document Repository Integration<br />
• Finance Facilities<br />
– Currency<br />
– Party<br />
– General Ledger<br />
• Electronic Commerce Facilities<br />
– Negotiation<br />
– Public Key Infrastructure<br />
• Manufacturing Facilities<br />
– Product Data Management<br />
– High-Level Architecture (HLA Simulation)<br />
• Telecommunications Facilities<br />
– A / V Stream Control<br />
– Notification<br />
18.09.2002 INF 312, Ifi, UiO 33<br />
OMG: CORBA Used to Create an OODBS<br />
<strong>Object</strong> Services<br />
interface repository<br />
lifecycle services<br />
transaction management<br />
…<br />
<strong>Object</strong> Request Broker<br />
method<br />
method<br />
method<br />
method<br />
method<br />
method<br />
method<br />
method<br />
method<br />
method<br />
method<br />
<strong>Object</strong> method<br />
<strong>Object</strong><br />
<strong>Object</strong><br />
method <strong>Object</strong><br />
method<br />
method<br />
method<br />
network-accessible objects<br />
method<br />
method<br />
method<br />
<strong>Object</strong> method<br />
<strong>Object</strong><br />
<strong>Object</strong><br />
method <strong>Object</strong><br />
method<br />
method<br />
method<br />
18.09.2002 INF 312, Ifi, UiO 35<br />
OMG: Vertical (Domain) Facilities<br />
• Telecommunications cont.<br />
– CORBA/TMN and CORBA/IN Interworking Facilities<br />
– Log Facility<br />
• Transportation<br />
– Air Traffic Control HCI Facility<br />
• Healthcare<br />
– Person Identifier Service<br />
– Lexicon Query Service<br />
• Utilities<br />
– Utility Management System (in process)<br />
• Life Science Research<br />
– Biomolecular Sequence Analysis (in process)<br />
– Genome Mapping (in process)<br />
• Sigs: C4I, GIS, Analytical Data Mgmt, Distributed Simulation, …<br />
18.09.2002 INF 312, Ifi, UiO 34<br />
OMG: Application Access to an OODBS<br />
Application<br />
Program<br />
method<br />
method<br />
method<br />
method<br />
application<br />
structures<br />
or objects<br />
method<br />
method<br />
method<br />
method<br />
method<br />
method<br />
method<br />
method<br />
ODBMS<br />
<strong>Database</strong> (persistent objects)<br />
method<br />
method<br />
method<br />
<strong>Object</strong> method<br />
<strong>Object</strong><br />
<strong>Object</strong><br />
method <strong>Object</strong><br />
method<br />
method<br />
method<br />
method<br />
method<br />
method<br />
<strong>Object</strong> method<br />
<strong>Object</strong><br />
<strong>Object</strong><br />
method <strong>Object</strong><br />
method<br />
method<br />
method<br />
18.09.2002 INF 312, Ifi, UiO 36
OMG Persistent State Service<br />
Interfaces<br />
ORB domain Datastore domain<br />
Servants<br />
external interface internal interface<br />
18.09.2002 INF 312, Ifi, UiO 37<br />
PSS: Sub-Storagetyping<br />
• If type_B is a subtype of type_A, and<br />
if store_B is a storagehome for type_B, and<br />
if store_A is a storagehome for type_A,<br />
then store_B must be a subtype of store_A.<br />
type_A<br />
type_B<br />
store_A<br />
store_B<br />
18.09.2002 INF 312, Ifi, UiO 39<br />
PSS: Basic Concepts - 1<br />
• Basic Concepts<br />
– Datastore<br />
• Provides persistent storage for object data, may be a RDBS,<br />
OODBS, ORDBS or file system<br />
– Abstract Storagetype<br />
• The declared type of stored data to persistently encode an<br />
object type (struct)<br />
– Storagetype<br />
• An implementation of an Abstract Storagetype<br />
– Abstract Storagehome<br />
• The declared type of a container to store instances of an<br />
Abstract Storagetype<br />
– Storagehome<br />
• An implementation of an Abstract Storagehome, stores<br />
instances of its corresponding Storagetype<br />
18.09.2002 INF 312, Ifi, UiO 38<br />
PSS: Basic Concepts - 2<br />
• Basic Concepts, cont.<br />
– Catalog<br />
• Provides access to a storagehome<br />
– PSDL<br />
• Superset of IDL, used to declare PSS entities<br />
• IDL + abstract storagetype, abstract storagehome, storagetype,<br />
storagehome, catalog<br />
– Session<br />
• Kind of catalog, provides transactional semantics<br />
– Storage <strong>Object</strong><br />
• A persistent state stored for an object. Is not a CORBA object,<br />
cannot be invoked, has a pid, not a CORBA Ref<br />
– Storage <strong>Object</strong> Incarnation<br />
• A CORBA object (in a process) bound to a Storage <strong>Object</strong><br />
18.09.2002 INF 312, Ifi, UiO 40
In file People.psdl<br />
abstract storagetype Person {<br />
readonly state long social_security_number;<br />
state string full_name;<br />
state string phone_number;<br />
};<br />
abstract storagehome PersonHome of Person {<br />
Person create(in long ssn, in string full_name, in string<br />
phone);<br />
};<br />
catalog People {<br />
provides PersonHome person_home;<br />
};<br />
18.09.2002 INF 312, Ifi, UiO 41<br />
Using PSS<br />
CosPersistentState.ConnectorRegistry connectorRegistry<br />
= CosPersistentState.ConnectorRegistryHelper.narrow(<br />
myOrb.resolve_initial_references(“PSS”) );<br />
CosPersistentState.Connector connector<br />
= connectorRegistry.find_connector(“”);<br />
// create session<br />
CosPersistentState.Session mySession<br />
= connector.create_basic_session(<br />
org.omg.CosPersistentState.READ_WRITE,“”,parameters);<br />
// find person home (personHome is a storage home instance)<br />
PersonHome personHome = (PersonHome)<br />
mySession.find_storage_home(“PSDL:PersonHomeImpl:1.0”);<br />
// create person Knut<br />
Person p = personHome.create(00010154321, “Knut”, “2200 9000”);<br />
18.09.2002 INF 312, Ifi, UiO 43<br />
// In file PeopleImpl.psdl<br />
#include <br />
storagetype PersonImpl implements Person {};<br />
storagehome PersonStoreImpl of PersonImpl implements<br />
PersonStore {};<br />
Notes: Any change to a storage object incarnation is reflected in<br />
the persistent state of the corresponding storage object.<br />
(after commit, flush, osv.)<br />
18.09.2002 INF 312, Ifi, UiO 42<br />
Transparent Persistence<br />
// Java<br />
public interface JPerson {<br />
public long socialSecurityNumber();<br />
public String fullName();<br />
public void fullName(String newName);<br />
public String phoneNumber()<br />
public void phoneNumber(String newNumber);<br />
}<br />
public class JPersonImpl implements JPerson {<br />
private long _ssn;<br />
private String _name;<br />
private String _phoneNumber;<br />
public long socialSecurityNumber() { return _ssn }<br />
// etc.<br />
}<br />
18.09.2002 INF 312, Ifi, UiO 44
<strong>Object</strong>-Relational Data Mapping<br />
• When using “<strong>Object</strong>s” in an application,<br />
Where are the objects?<br />
– In the database only (ORDBMS?)<br />
– In both application and database (OODBMS)<br />
– In the application only (RDBMS)<br />
• Must create an <strong>Object</strong>-Relational mapping to overcome<br />
the impedance mismatch<br />
18.09.2002 INF 312, Ifi, UiO 45<br />
Changes for a DBMS<br />
• Types from Application <strong>Object</strong> Model<br />
• Schema<br />
• Access Paths (Indexes)<br />
• Clustering Strategies<br />
• DBMS<br />
18.09.2002 INF 312, Ifi, UiO 47<br />
Naive Architecture for a <strong>Database</strong><br />
get<br />
set<br />
get<br />
set<br />
get<br />
set<br />
What Changes?<br />
18.09.2002 INF 312, Ifi, UiO 46<br />
Encapsulated <strong>Database</strong> Architecture<br />
18.09.2002 INF 312, Ifi, UiO 48<br />
<<br />
>
<strong>Object</strong>-Relational Mapping References<br />
• Relational <strong>Database</strong> Access Layers (from PLoP 96)<br />
http://www.sdm.de/en/tec/pub/art/art/arcus/relz_abstract.htm<br />
• Connecting Business <strong>Object</strong>s to Relational <strong>Database</strong>s (from<br />
PLoP 98) http://www.joeyoder.com//papers/patterns/<br />
• Crossing Chasms (from PLoP 95)<br />
http://members.aol.com/kgb1001001/Chasms.htm<br />
• There are links to several whitepapers on the ODMG site<br />
http://www.odmg.org/library/whitepapers.htm#<strong>Database</strong><br />
• http://www.sun.com/software/javablend/index.html<br />
• http://www.rational.com/products/rose/whitepapers.jsp<br />
• There are many links to info on both OODBMSs and ORDBMSs<br />
at http://www.cetus-links.org/oo_db_systems_2.html<br />
18.09.2002 INF 312, Ifi, UiO 49<br />
<strong>Object</strong>-<strong>Oriented</strong> <strong>Database</strong>s (1. Generation)<br />
• Developed from object-oriented programming languages (PL)<br />
• Intermediate stadium: persistent object-oriented PL<br />
(persistence means data survives program run-time)<br />
• Incorporate most object-oriented concepts, but lack good<br />
support of several DBS concepts<br />
• Most important application domains: GIS (Geographic IS),<br />
CAD (Computer Aided Design) and Genome DBS<br />
18.09.2002 INF 312, Ifi, UiO 51<br />
Overview<br />
<strong>Object</strong> Data System Vendors<br />
• <strong>Object</strong>-<strong>Oriented</strong><br />
• <strong>Object</strong>-Relational<br />
<strong>Object</strong>-<strong>Oriented</strong> DBS (OODBS) standards<br />
• OMG: <strong>Object</strong> Model, OMA -> CORBA, POA, PSS<br />
• ODMG 3.0 version<br />
18.09.2002 INF 312, Ifi, UiO 50<br />
ODMG (<strong>Object</strong> <strong>Database</strong> Management Group)<br />
started in 1991<br />
voting members: other members:<br />
- <strong>Object</strong>Design - American Management <strong>Systems</strong><br />
- <strong>Object</strong>ivity - Anderson Consulting<br />
- Ontos - EDS<br />
- O2 Technology (Ardent) - Fujitsu<br />
- POET Software - Hewlett-Packard<br />
- Servio (Gemstone) - Intellitic<br />
(- SunSoft) - MITRE<br />
- Versant - Persistence Software<br />
- Sybase<br />
-UniData<br />
- Texas Instruments<br />
18.09.2002 INF 312, Ifi, UiO 52
ODMG (<strong>Object</strong> Data Management Group) Today<br />
Release 3.0 in 2000<br />
voting members: other members:<br />
- eXcelon (was <strong>Object</strong>Design) - CERN<br />
- <strong>Object</strong>ivity - Micro Data Base <strong>Systems</strong><br />
-POETSoftware -NEC<br />
- Sun Microsystems - Versant<br />
Plus 8 academic reviewers<br />
(Alagic, Dittrich, King, Liskov, Maier, Moss, Soloman, Zdonik)<br />
<strong>Object</strong> Data: OO and OR<br />
18.09.2002 INF 312, Ifi, UiO 53<br />
ODMG: Architecture<br />
- common architecture for ODS products<br />
- declarations for application schema (data + operations)<br />
- source program<br />
- schema declarations<br />
- applications access DBs, types must conform to declarations<br />
- DBs can be shared among applications on a network<br />
- DBMS: shared service for transaction and lock management<br />
18.09.2002 INF 312, Ifi, UiO 55<br />
The <strong>Object</strong> Data Standard (Version 3.0)<br />
Designed for ODS<br />
Main components:<br />
-(Architecture)<br />
- <strong>Object</strong> Model<br />
- <strong>Object</strong> Definition Language (ODL)<br />
- <strong>Object</strong> Query Language (OQL)<br />
- Language Bindings (OML - <strong>Object</strong> Manipulation Language)<br />
18.09.2002 INF 312, Ifi, UiO 54<br />
ODMG: <strong>Object</strong> Model<br />
- based in OMG specifications, ODMG object model is<br />
superset of OMG object model)<br />
- common data model to be supported by OODBS<br />
-- objects with OIDs<br />
-- object behavior, state of objects, named objects<br />
-- operation signatures<br />
-- properties (attributes or relationships)<br />
-- attribute / relationship signatures<br />
-- collection types<br />
-- inheritance<br />
-- ...<br />
- subset of the object model provides interoperability across PLs<br />
18.09.2002 INF 312, Ifi, UiO 56
ODMG: <strong>Object</strong> Definition Language (ODL)<br />
ODL is intended to define object types that can be implemented<br />
in a variety of PLs:<br />
- syntax for object model based on IDL (CORBA) +<br />
referential integrity and collections<br />
- used to define application schema; schema can subsequently<br />
be translated into declarations of desired PL<br />
18.09.2002 INF 312, Ifi, UiO 57<br />
ODMG: <strong>Object</strong> Manipulation Language (OML)<br />
- Language Bindings (C++, Smalltalk, Java) -<br />
- based on extending a PL syntax and semantics in order to<br />
provide DBS capabilities rather than embedding statements in<br />
SQL or another language<br />
-> goal: seamlessness<br />
- one single unified type system across PL and DBS<br />
- PL-specific binding respects the syntax and semantics of the<br />
base PL -> small set of extensions to the base PL<br />
- 3 components of PL binding: ODL, OQL, OML<br />
18.09.2002 INF 312, Ifi, UiO 59<br />
ODMG: <strong>Object</strong> Query Language (OQL)<br />
- declarative query language for querying DB objects<br />
- based on SQL syntax whereever possible<br />
-> simple OQL queries<br />
-> complex OQL queries<br />
-> OQL as embedded language<br />
18.09.2002 INF 312, Ifi, UiO 58<br />
ODMG C++ Binding<br />
class d_<strong>Object</strong> {<br />
public:<br />
mark_modified(); //mark <strong>Object</strong> as modified<br />
void* operator new(size_t size);<br />
void* operator new(size_t size, const d_ Ref_Any &cluster,<br />
const char *typename);<br />
void* operator new(size_t size, d_<strong>Database</strong> *database,<br />
const char *typename);<br />
virtual void d_activate();<br />
virtual void d_deactivate();<br />
}<br />
An object which is an instance of a class that<br />
inherits from d_<strong>Object</strong> is said to be<br />
“persistence capable”.<br />
18.09.2002 INF 312, Ifi, UiO 60
ODMG C++ Binding (cont.)<br />
template class d_Ref {<br />
public:<br />
d_Ref();<br />
d_Ref(T *fromPtr); //constructor<br />
d_Ref(const d_Ref&); //constructor<br />
...<br />
T* operator->(); //dereference the Ref<br />
operator T*(); //applies to non-const<br />
T& operator T*() const;<br />
void delete_object(); //delete object - all copies<br />
...<br />
}<br />
d_Ref is an example of the Proxy Design Pattern<br />
18.09.2002 INF 312, Ifi, UiO 61<br />
Typical Ref-> Implementation<br />
T* operator->() { //dereference the Ref<br />
if (cachePtr != 0)<br />
return cachePtr;<br />
else {<br />
// validate myDB exists, permissions, etc, then<br />
...<br />
<strong>Database</strong>Page* temp = new <strong>Database</strong>Page;<br />
// read database page containing object oid<br />
// from database myDB into temp<br />
...<br />
// locate object oid in temp<br />
...<br />
cachePtr = ... // Ptr to local object copy<br />
}<br />
}<br />
18.09.2002 INF 312, Ifi, UiO 63<br />
Typical Proxy Implementation<br />
aRef<br />
Type* 0<br />
<strong>Database</strong>Name myDB<br />
db_<strong>Object</strong>_Id<br />
boolean dirty<br />
...<br />
oid<br />
0<br />
18.09.2002 INF 312, Ifi, UiO 62<br />
}<br />
Typical Ref-> Result<br />
aRef<br />
Type*<br />
<strong>Database</strong>Name<br />
db_<strong>Object</strong>_Id<br />
boolean dirty<br />
...<br />
myDB<br />
oid<br />
0<br />
Memory<br />
<strong>Database</strong><br />
18.09.2002 INF 312, Ifi, UiO 64<br />
}<br />
Memory<br />
<strong>Database</strong>
<strong>Object</strong> Query Language (OQL)<br />
• OQL is the query language of the ODMG standard<br />
• OQL is a declarative (not procedural) language allowing<br />
to define what you want to know, instead of how you get<br />
to the result<br />
• OQL can be used as a stand-alone query language to<br />
write ad hoc queries<br />
• OQL can also be used from PLs like C++, Smalltalk, and<br />
Java<br />
18.09.2002 INF 312, Ifi, UiO 65<br />
Conventions (like Eaglestone & Ridley)<br />
• OQL reserved words are written in bold font<br />
• Names of classes (of mutable objects) are written<br />
beginning with a capital letter (stor forbokstav)<br />
• Names of attributes, relationships, operations and<br />
other variable names are written in lower case (små<br />
bokstaver)<br />
18.09.2002 INF 312, Ifi, UiO 67<br />
Sets or Navigation? Both ways!<br />
• OQL supports declarative queries that return a set of objects<br />
(like SQL does for relational databases).<br />
– The result to such queries is an collection object containing<br />
a collection of objects, an object, a collection of literals, or a<br />
literal (or undefined)<br />
• OQL also supports navigational queries that use paths based<br />
on pointers and relationships to navigate in the database to<br />
locate the desired data (like the network data model).<br />
– The result of a navigational query is the desired object in<br />
the database, from which one can use a PL for further<br />
computation.<br />
18.09.2002 INF 312, Ifi, UiO 66<br />
select distinct E.title<br />
from Employees E<br />
where department = 4<br />
Result in SQL:<br />
Title<br />
Engineer<br />
Consultant<br />
Salesman<br />
Secretary<br />
Example: set query<br />
Result in OQL:<br />
:Set<br />
:String “Engineer”<br />
:String “Consultant”<br />
:String “Salesman”<br />
:String “Secretary”<br />
18.09.2002 INF 312, Ifi, UiO 68
OQL: a Typed Expression Language<br />
• A query is a query expression with no bound variables<br />
• An expression returns an object or a literal<br />
• With unary and binary operators , expressions can be built<br />
recursively from sub-expressions:<br />
or <br />
• The type of sub-expressions are subject to restrictions<br />
depending on the type checking rules for the operator used.<br />
• ::= | <br />
18.09.2002 INF 312, Ifi, UiO 69<br />
OQL Grammar primaryExpr<br />
primaryExpr ::= conversionExpr<br />
| collectionExpr<br />
| aggregateExpr<br />
| undefinedExpr<br />
| objectConstruction<br />
| structConstruction<br />
| collectionConstruction<br />
| identifier [ argList ]<br />
| queryParam<br />
| literal<br />
| ( query )<br />
18.09.2002 INF 312, Ifi, UiO 71<br />
Recursing on OQL expr<br />
query In the OQL grammar, there is a<br />
selectExpr | expr production rule from the undercastExpr<br />
lined non-terminal to the next line<br />
orExpr | ( type ) castExpr<br />
orelseExpr { or orelseExpr }<br />
andExpr { orelse andExpr }<br />
quantifierExpr { and quantifierExpr }<br />
andthenExpr | for all inClause : andthenExpr | …<br />
equalityExpr { andthen equalityExpr }<br />
relationalExpr { ( = | != ) relationalExpr } | …<br />
additiveExpr { ( < | | >= ) additiveExpr } …<br />
multiplicativeExpr { + multiplicativeExpr } | …<br />
inExpr { * inExpr }<br />
unaryExpr { in unaryExpr }<br />
+ unaryExpr | … | postfixExpr<br />
primaryExpr { ( . | -> ) identifier [ argList ] } | …<br />
( query )<br />
18.09.2002 INF 312, Ifi, UiO 70<br />
Example OQL Queries<br />
17 literal with value 17 of type integer<br />
Pindex.lookup(“Earl”) set of Person objects with name=“Earl”<br />
or the unique Person object with name = “Earl”<br />
assuming type(Pindex) is dictionary<br />
Cities set of City objects in the database<br />
assuming City.extent is named Cities and there are no duplicates<br />
select c.name bag of String (names of cities) where the city<br />
from c in Cities has more than 5 museums in the database<br />
where c.name in (<br />
select m.name<br />
from m in Museums<br />
group by m->city<br />
having count > 5)<br />
18.09.2002 INF 312, Ifi, UiO 72
OQL Collections<br />
collectionConstruction ::= array ( [ valueList ] )<br />
| set ( [ valueList ] )<br />
| bag ( [ valueList ] )<br />
| list ( [ valueList ] )<br />
| list ( listRange )<br />
Class City {array(museum) museums }<br />
oslo.museums[2]<br />
norskMuseums = oslo.museums+bergen.museums<br />
Type of e1+e2: if type(e1) = list(t1) and type(e2) = list(t2)<br />
(e1||e2) and t1 is compatible with t2,<br />
array, too then type(e1+e2) = list(lub(t1,t2))<br />
18.09.2002 INF 312, Ifi, UiO 73<br />
Set Operators<br />
Set operators: union, intersect, and except (minus or<br />
difference)<br />
Operators work with multiplicity on bags.<br />
bag(1,2) union bag(1,2,3)) = a bag of 1,2,1,2,3<br />
bag(1,2,1,3) minus bag(2) = a bag of 1,1,3<br />
distinct(bag(1,2,1,2,3)) = a set of 1,2,3<br />
element({person1}) = Person: person1<br />
18.09.2002 INF 312, Ifi, UiO 75<br />
Conversion Operators for Collections<br />
collectionExpr ::= first ( query )<br />
| last ( query )<br />
| unique ( query )<br />
| exists ( query )<br />
First(select students from course where course.name=“INF 312”)<br />
conversionExpr ::= listtoset ( query )<br />
| element ( query )<br />
| distinct ( query )<br />
| flatten ( query )<br />
flatten(list(set(1,2,3),set(3,4,5,6),set(7)) = a set of 1,2,3,4,5,6,7<br />
flatten(list(list(1,2),list(1,2,3)) = a list of 1,2,1,2,3<br />
flatten(set(list(1,2),list(1,2,3)) = a set of 1,2,3<br />
18.09.2002 INF 312, Ifi, UiO 74<br />
OQL selectExpr<br />
selectExpr ::= select [ distinct ]<br />
projectionAttributes<br />
fromClause [ whereClause ] [ groupClause ]<br />
[orderClause ]<br />
select f ( y [, partition] )<br />
from x in X<br />
where p(x) scope of x<br />
group by y: g(x)<br />
having h(y, partition)<br />
order by o(y, partition)<br />
scope of y<br />
18.09.2002 INF 312, Ifi, UiO 76
Complex Example<br />
For each museum, find all tours with a capacity of more than 20 that<br />
have the same theme as some tour that already visits the museum.<br />
select struct( M: m,<br />
Tours: flatten ( select ( select s<br />
from s in Tour<br />
where s.theme = t.theme<br />
and s.capacity > 20 )<br />
from t in Tour<br />
where m in ( select distinct w.what<br />
from w in t.description ) ) )<br />
from m in Museum<br />
Type of result = struct(Museum, set(Tour))<br />
18.09.2002 INF 312, Ifi, UiO 77<br />
OQL is not Computationally Complete!<br />
LEAST_FIXED_POINT operator cannot be expressed in<br />
OQL<br />
OQL is computationally supplemented by an OO<br />
programming language through the ODMG programming<br />
language bindings (DML).<br />
18.09.2002 INF 312, Ifi, UiO 78