Using Object-Oriented Databases: A Step-By-Step Tutorial

Walk through the development of an OODB application step-by-step–complete with source code–so you can better understand how an OODB could tie into your apps.
by Steve Franklin

o you're interested in object-oriented databases (OODBs), but you're still not quite sure how you'd use them. My previous article, "Object-Oriented Databases Are Worth a Closer Look", discussed the pros and cons of OODBs but didn't provide any practical examples of how the technology works. Luckily, a major benefit of many OODB solutions is the ability to start coding an application without immediate integration or prior knowledge of the OODB itself.

In this article, I'll walk you through the evolution of a simple application from a pure Java app to an OODB-enabled Java app. I'll demonstrate how to create the database on the fly and give you the source code for the whole solution so you can better understand how to tie an OODB into your apps.

First Things First
Before I get to the source code, let's get a few details out of the way:

Required Tools
First, I assume you have access to a fairly recent Unix or Windows OS. If you need to duplicate a Unix environment on your Windows machine, you could look into cygwin, although the Windows scripts I have provided run under Windows command prompt configurations (tested only on Windows 2000 and Win95). Table 1 lists all the required tools.

Tool Type Required Software Version Notes
JDK J2SE 1.31 Jikes provides a very nice alternative for compilation.
XML Parser Xerces-J 1.4.1 Refer to my previous DevX article, "XML Parsers: DOM and SAX Put to the Test", for a full discussion of XML parser options.
OODB ObjectStore PSE 6.0.5 PSE See the Picking the OODB section below.
Table 1: Required Tools for OODB App

The Design of the System
For our demonstration, I will build a simple online phone book that manages phone entries, allowing query, insertion, update, and delete functionality. Since the migration from a database-independent design to an OODB design is fairly seamless, your system shouldn't be disrupted. The UML diagram shown in Figure 1 is a first stab at the design, before I planned for a specific OODB solution.

Figure 1  
Figure 1. The PhoneApp Design Before Employing an OODB

Because the application is such a simple one, the design is not overly elegant. The application runs from the Admin class and the data layer consists of just four classes: Phonebook, PhonebookEntry, PhoneRegion, and PhoneRegionList. All this information should be persistent and managed by some form of database management system. That's where our OODB will come in. (I skipped a business rules layer altogether to keep the demonstration simple.)

As you probably noticed in Table 1, I also decided to use an XML parser. The XMLPhoneEntries class manages parsing and retrieval of phone entries that have been stored in an XML file for batch upload. It uses Xerces-J, a very fast and popular XML parser. (Find more information on XML parsers in my previous DevX article "XML Parsers: DOM and SAX Put to the Test.")

Picking the OODB
Choosing an OODB for this demo was not trivial. No two OODBs work identically and they have major functional differences amongst them. Whereas most relational databases are fairly similar in their functionality, each OODB vendor implements its database product quite differently.

I ended up choosing ObjectStorePSE from ObjectDesign Inc.. ObjectStore is one of the more popular OODBs. It has a fairly compact installation and can be downloaded for a 30-day trial. However, ObjectStore certainly shared some of the OODB disadvantages I discussed in "Object-Oriented Databases Are Worth a Closer Look".

 
Building the Application

In this Article
Introduction Creating A Persistent Class
Building the Application Performing Updates



Read Part 1 of the OODB series: "Object-Oriented Databases Are Worth a Closer Look"







FEATURE SOFTWARE:
SQLDC
Create SQL applications quickly and easily.
Buy Now!

FEATURE BOOK:
VBCommander
Speed app and component design time with this set of more than 20 add-in tools.
Buy Now!


The Database Development Zone has all the content and resources you need to fine-tune your data access apps.

Download the code from this article!

Read Part 1 of the OODB series: "Object-Oriented Databases Are Worth a Closer Look"

Read "XML Parsers: DOM and SAX Put to the Test" for a full discussion of XML parser options.

Join the discussions in the DevX Database Design forum





 
Sponsored Links

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map
Jupiterweb networks

internet.comearthweb.comDevx.comClickZ

Search Jupiterweb:

Jupitermedia Corporation has four divisions:
JupiterWeb, JupiterResearch, JupiterEvents, and JupiterImages

Copyright 2004 Jupitermedia Corporation All Rights Reserved.
Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Jupitermedia Corporate Info | Newsletters | Tech Jobs | E-mail Offers

Copyright Information/Privacy Statement