| By Rick Grehan | Article Rating: |
|
| May 9, 2007 11:00 AM EDT | Reads: |
14,219 |
When your next Java application calls for a database backend, before you reach for JDBC and a relational database, stop for a moment and consider another possibility: an object database.
As we hope to show in this article, an object database may not only simplify coding chores, but its capabilities may enable application solutions that you would otherwise not thought of.
Of course, the most apparent benefit you'll get from using an object database is the fact that you won't have to wrestle with two paradigms - object and relational - in a single application. The design of your application code and the design of your database will be object-oriented throughout.
However, the advantages you'll derive from an object database go beyond the simple fact that an object database is more easily incorporated into a project already written in an object- oriented language. One exceptional advantage of an object database is its ability to store structure as well as data. Put another way, its ability to preserve the structure that you've already built into your application. With a relational database, you have to tear down and reassemble that structure as you move data between the application and the database.
Typically, when one thinks of a database, one thinks of a repository of data. In a relational database, the information in the database is organized - more or less - along the lines of normalized data corralled into the proper tables. Data is arranged in "tuples," which tends to gather related information together. But any sort of higher-level data structures must be implemented in the SQL code (procedures) that access the data. Not so with an object database, which can mingle data with data structures in the same database. In fact, with the "right" object database engine, you can add new data structures to an existing database at will (or, rather, as the situation dictates).
We will illustrate what we mean using an example that combines two data structures. As our database engine, we will choose the open source object database db4o (available from www.db4objects.com).
Homemade Thesaurus
We will use as our illustration the data structures that one would employ to create something like ThinkMap's Visual Thesaurus (www.visualthesaurus.com). Visual Thesaurus is a clever visual interface that represents words as existing in a network of connected nodes. Each node is a word, and the connections represent relationships between synonyms.
Our intent here is not to create our own version of Visual Thesaurus, instead, we're going to imagine what sorts of data structures might exist "behind" the user interface of a Visual-Thesaurus-like application and consider how we might represent those structures. Finally, we want to illustrate how we could use an object database to store our imaginary thesaurus' data.
Let's design our data structures from the bottom up. So, on the ground floor, we'll need a structure for storing each word. This structure will need to take into account the fact that a given word often has multiple parts of speech. Furthermore, each part of speech will connect to a different network of synonyms. Consequently, we'll decompose this structure into two classes. First, a POSSynonyms class that will identify the part of speech and hold an array of references to the synonyms corresponding to that part of speech. The class looks like this:
public class POSSynonyms
{
private int pos; // Part of speech
private ThesaurusEntry[] synonyms; // Synonyms
... POSSynonyms methods ...
}
Obviously, this class depends on the ThesaurusEntry class, which is shown below:
public class ThesaurusEntry
{
private string theWord:
private POSSynonyms[] posSyns;
... ThesaurusEntry methods ...
}
Published May 9, 2007 Reads 14,219
Copyright © 2007 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Rick Grehan
Rick Grehan is a QA engineer at Compuware's NuMega Labs, where he has worked on Java and .NET projects. He is also a contributing editor for InfoWorld Magazine. His articles have appeared in Embedded Systems Programming, EDN, The Microprocessor Report, BYTE, Computer Design, and other journals. He is also the coauthor of three books on computer programming.
- 4th International Cloud Computing Conference & Expo Starts Today
- Deputy CIO of the CIA to Keynote 1st Annual GovIT Expo
- Publishing Synergy: Blog, Twitter and Ulitzer
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Roadmap to Create Profitable Cloud Computing Industry
- Oracle-Sun: IBM Reportedly Behind Delay
- Virtualization Journal Opens "Readers' Choice Awards" Nominations
- Citrix Aims To Cripple VMware’s Cloud Designs
- 5th International Cloud Computing Conference & Expo: Call for Papers Is Open
- Java Kicks Ruby on Rails in the Butt
- Interviewing Java Developers With Tears in My Eyes
- 4th International Cloud Computing Conference & Expo Starts Today
- Deputy CIO of the CIA to Keynote 1st Annual GovIT Expo
- Ruby-on-Rails Apps Get Cloud Lift
- Publishing Synergy: Blog, Twitter and Ulitzer
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- Adobe Flex 4 Goes to Public Beta
- SingTel Throws in its Lot with the Cloud
- Adobe ColdFusion 9 and ColdFusion Builder Public Betas Now Available
- After Ubuntu, Windows Looks Increasingly Bad, Increasingly Archaic, Increasingly Unfriendly
- SCO CEO Posts Open Letter to the Open Source Community
- Simula Labs Launches Hosted Delivery Platform To Enable Enterprise Open Source Adoption
- Where Are RIA Technologies Headed in 2008?
- Source Claims SCO Will Sue Google
- How Open Is "Open"? – Industry Luminaries Join the Debate
- Latest SCO News is Plain Weird
- IBM Tells SCO Court It Can't Find AIX-on-Power Code
- SCO Claims Linux Lifted ELF
- Flashback: Investing in 'Professional Open Source' - Exclusive 2004 Interview with David Skok, Matrix Partners


































