Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

Interfacing C++ with Relational Databases

Oracle Database Tips by Donald Burleson

With the increasing popularity of object-oriented technology, many relational database shops want the ability to take advantage of C++ applications while continuing to use their relational databases.  The widespread acceptance of object technology has lead many companies to the conclusion that they must embrace object-orientation, but they remain skeptical about the maturity of the object-oriented database (OODB) technology.  Many companies are averse to risk and do not want to embrace one of the nascent OODB offerings, and they cannot wait for the object/relational databases.  Other companies who have invested millions of dollars in relational database systems want to continue with a relational architecture without missing out on the benefits of object technology.

When interfacing object-oriented languages with relational databases there is a  problem encountered when using SQL with a general-purpose object-oriented programming language, in which an "Impedance mismatch" is created.

There are two aspects to this impedance mismatch between SQL and objects:

  1. Difference in programming paradigms, for example, between a declarative language such as SQL and an imperative language such as C++.

  2. A  mismatch in the type systems, causing a loss of information to occur at the interface.  The DML, in most relational database systems does not support the computational completeness to express complex mathematical manipulations of data common to engineering design.  However OODBMS's,  provide database extensions to computationally complete programming languages, like C++ and  Smalltalk, that are capable of handling complex mathematical manipulations typical of large-scale programs that are common to engineering design.

Regardless of the promises of the relational database vendors, there are those who wish to enjoy the benefits of a robust and mature database while continuing to pursue object technology.  However, there are drastic differences between object technology and relational databases.  In a true OODB, object persistence (storing the object) is achieved by calling a method for the object that makes the object reside in permanent disk storage.  In other words, persistence is just another method that is associated with the object.  This is very different from a relational database where a row can be inserted from any program at any time.

Unlike relational databases, the OODB offerings also have a very tight coupling of the database with the host programming language.  Consequently OODB's generally are designed with a specific language in mind, such as C++ or SmallTalk.  Relational databases such as Oracle are language independent, and many Oracle shops are having success writing C++ applications and running them through the Pro*C precompiler.

The Method:

There are many different approaches to using a relational database with an object-oriented application, and this text offers only one of many different approaches.  However, all of the approaches involve some common factors and procedures.   The goal of "stuffing" an object into a relational table generally involves the following steps: 

  1. Document the object structure for the application.

            (Using Booch diagrams, Rumbaugh diagrams, etc.)

  1. Review all methods with the C++ application. 

  2. Review the object navigation and create logical pointers.

  3. Add object extensions to manage internal pointers.

  4. For each class, map the data items and pointers to a relational table.

  5. Write C/SQL snippets to move the object data and pointers into the table row.

  6. Re-write the I/O to utilize the logical pointers.

While these steps are not exhaustive, they describe the major steps in converting a C++ application to function with a relational database.  While these are the steps, it must be stressed that every application is different.  A C++ application that uses logical pointers, avoids "arrays of pointers" and isolates object I/O is very easy to back-end into a relational database.  On the other hand, a C++ application that uses physical object address as pointers (i.e. capturing the address of an object and embedding it in another object to establish a relationship), utilizes arrays of pointers, and has separate I/O statements within each method can be very difficult to back-end to a relational database.

This chapter will illustrate some of these issues and provide examples on how to write C++ code that can utilize relational engines for persistent object storage.

 


 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.