1 / 20

ORACLE 9i

ORACLE 9i. Defining Objects in SQL and the Oracle Type Translator. 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.

regis
Download Presentation

ORACLE 9i

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ORACLE 9i Defining Objects in SQL and the Oracle Type Translator

  2. 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

  3. 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

  4. 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.

  5. 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.

  6. 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.

  7. Objects with SQL and OTT • Overview • Defining objects in SQL • OTT usage and C++ binding • Exploiting Oracle • Summary and Outlook

  8. 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

  9. Embedded Object Inherited Objects to-one-link 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 Galaxy_O Star_O Spectrum_O

  10. Objects with SQL and OTT • Overview • Defining objects in SQL • OTT usage and C++ binding • Exploiting Oracle • Summary and Outlook

  11. Object Type Translator SQL DDL INTYPE file OTT Type Definitions MAPFILE file CPPFILE file HFILE file Database Server OCCI Source Compiler OCCI library Linker Object file Executable 2 1 3 4 5

  12. OTT Usage OTT userid=pkunszt/orapasswd code=cppintype=sky_in.typ outtype=sky_out.typmapfile=sky_map.cpp hfile=sky_ott.h cppfile=sky_ott.cpp sky_ott.h sky_ott.cpp sky_map.hsky_map.cpp sky_in.typ CASE = SAMETYPE "Coordinate_O" TYPE "SkyObject_O" TYPE "Star_O"TYPE "Galaxy_O" TYPE "Spectrum_O" sky_out.typ

  13. Generated classes only contain Oracle types and code User classes can inherit from generated ones to add methods and transient data SkyObject Coordinate Galaxy Star Spectrum Adding your code SkyObject_O Coordinate_O Galaxy_O Star_O Spectrum_O

  14. OTT replaces SQL name with userclass name Nested types, references now point to userclass, user-defined methods can be used Letting OTT know sky_in.typCASE SAMETYPE "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

  15. GENERATE clause also affects inheritance User types cannot have direct inheritance, e.g. SkyObject not a direct base class of Star Inheritance scheme SkyObject SkyObject_O PObject Star Star_O

  16. Objects with SQL and OTT • Overview • Defining objects in SQL • OTT usage and C++ binding • Exploiting Oracle • Summary and Outlook

  17. 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

  18. 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

  19. 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

  20. 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

More Related