OCCI issues DG

Download Report

Transcript OCCI issues DG

CERN/IT/DB
ORACLE 9i
Defining Objects in SQL and
the Oracle Type Translator
CERN/IT/DB
Objects with SQL and OTT
Overview
 Objects in SQL99 and Oracle
 Types and Tables
 Mapping to C++ classes using OTT
Defining objects in SQL
OTT usage and C++ binding
Exploiting Oracle
Summary and Outlook
CERN/IT/DB
Overview:
Objects in SQL99
Introduction of User Defined Types (UDT)
Introduction of unique Reference (Object ID)
“A type is a class”
“A row is an object”
Introduction of single inheritance
Methods, functions, procedures and
computational completeness
CERN/IT/DB
Overview:
Objects in Oracle9i
SQL99 Object model is implemented.
Introduces an explicit OBJECT type.
 Has persistent (referenceable) and embedded
(nonreferenceable) Objects (also called ‘value
instances’).
 Transient instances of persistent objects.
SQL objects can be mapped to C++ classes
using the Object Type Translator utility.
CERN/IT/DB
Overview:
Types and Tables
An Oracle Object Type is like a 'typedef'
of a structure.
An Oracle Table (of Object types) holds
a set of persistent Type instances.
CERN/IT/DB
Overview:
Mapping to C++
The User Defined Types (objects in
Oracle) are defined in a user's schema
using the SQL statement
CREATE TYPE typename AS OBJECT
The Object Type Translator utility (OTT)
generates C++ wrapper classes for
objects.
CERN/IT/DB
Objects with SQL and OTT
Overview
Defining objects in SQL
OTT usage and C++ binding
Exploiting Oracle
Summary and Outlook
CERN/IT/DB
SQL Example
CREATE TYPE "Coordinate_O"
AS OBJECT (
"ra" NUMBER,
"dec" NUMBER
);
CREATE TYPE "SkyObject_O"
AS OBJECT (
"coord" "Coordinate_O",
"brightness" NUMBER,
"constellation" CHAR(20)
) NOT INSTANTIABLE NOT FINAL;
CREATE TABLE "SkyObject_tab"
OF "SkyObject_O"
SkyObject
Coordinate
Embedded Object
CERN/IT/DB
SQL Example
CREATE TYPE "Spectrum_O"
AS OBJECT ( "specData" BLOB );
CREATE TABLE "Spectrum_tab"
OF "Spectrum_O"
CREATE TYPE "Star_O"
UNDER "SkyObject_O" (
"classification" CHAR(5),
"metallicity" NUMBER,
"spec" REF "Spectrum_O"
);
CREATE TYPE "Galaxy_O"
UNDER "SkyObject_O" (
"deVaucouleurClass" CHAR(5),
"petrosianRadius" NUMBER
);
SkyObject_O
Coordinate_O
Embedded Object
Galaxy_O
Inherited Objects
Star_O
to-one-link
Spectrum_O
CERN/IT/DB
Objects with SQL and OTT
Overview
Defining objects in SQL
OTT usage and C++ binding
Exploiting Oracle
Summary and Outlook
CERN/IT/DB
Object Type Translator
SQL DDL
2
INTYPE file
1
OTT
Type
Definitio
ns
MAPFILE
file
CPPFILE
file
Databas
e
Server
3
HFILE file
OCCI
Source
4
Compil
er
OCCI library
Linker
Object file
5
Executable
CERN/IT/DB
OTT Usage
OTT userid=pkunszt/orapasswd code=cpp
intype=sky_in.typ outtype=sky_out.typ
mapfile=sky_map.cpp hfile=sky_ott.h cppfile=sky_ott.cpp
sky_in.typ
CASE
TYPE
TYPE
TYPE
TYPE
TYPE
= SAME
"Coordinate_O"
"SkyObject_O"
"Star_O"
"Galaxy_O"
"Spectrum_O"
sky_ott.h
sky_ott.cpp
sky_map.h
sky_map.cpp
sky_out.typ
CERN/IT/DB
Adding your code
Generated classes
only contain Oracle
types and code
User classes can
inherit from
generated ones to
add methods and
transient data
SkyObject_O
SkyObject
Coordinate_O
Coordinate
Galaxy_O
Galaxy
Star_O
Star
Spectrum_O
Spectrum
CERN/IT/DB
Letting OTT know
OTT replaces SQL
name with
userclass name
Nested types,
references now
point to userclass,
user-defined
methods can be
used
sky_in.typ
CASE SAME
TYPE "Coordinate_O"
GENERATE Coordinate_O AS Coordinate
TYPE "SkyObject_O"
GENERATE SkyObject_O AS SkyObject
TYPE "Star_O"
GENERATE Star_O AS Star
TYPE "Galaxy_O"
GENERATE Galaxy_O AS Galaxy
TYPE "Spectrum_O"
GENERATE Spectrum_O AS Spectrum
CERN/IT/DB
Inheritance scheme
GENERATE clause also affects inheritance
User types cannot have direct inheritance,
e.g. SkyObject not a direct base class of Star
SkyObject
SkyObject_O
Star
Star_O
PObject
CERN/IT/DB
Objects with SQL and OTT
Overview
Defining objects in SQL
OTT usage and C++ binding
Exploiting Oracle
Summary and Outlook
CERN/IT/DB
Inheritance possibilities
Inside Oracle schema only single
inheritance
Outside 'proper' C++ with multiple
inheritance
Can have 'mixed' persistent classes by
inheriting from a persistent and a
transient class
CERN/IT/DB
Stored Procedures
Object types can have server-side
methods written in e.g. Java
Maps to a method in C++
Very powerful for various applications
 server-side processing
 use Oracle's built-in JVM
 use Oracle's querying capabilities
CERN/IT/DB
Summary
Complex data modeling using Oracle9i's
object extensions is possible
SQL is the modeling language
C++ mapping similar to JDBC
All purely relational features are also
accessible
CERN/IT/DB
Outlook
Internals of C++ mapping need to be
understood (see test plan)
Collect requirements and possibilities of
automating OTT tasks
Outstanding showstoppers (bugs
preventing further progress) should be
fixed soon, close contact with Oracle