Datasheet

create table cd (
title varchar,
artist varchar
);
From the XML, we can easily build a class like this:
public class cd {
String title;
String artist;
}
Having the XML representation creates an additional level of complexity and processing required to go
from an object to the database. This processing can be extensive, given the complexity of the objects in
an application.
Object-Oriented Database Systems
When object-oriented programming first began to be used, the issue of storing objects for later use was
an important topic. The most widely used component for storage is a database, so several companies
started down the path of developing a new database technology used specifically to store objects. The
object-oriented database system handles the storing and loading of objects in a transparent manner. The
complexity in the system comes from querying the database. For example, we might have a query like
this:
select x from user x where x.name = \"John Doe\"");
The database will access all the user objects in the database and return those whose name attribute is
equal to “John Doe”. The database needs to be designed in a manner that automatically allows the query
to access the attributes of the stored objects.
Although these new database systems can transparently store and load objects to Java or other object-
oriented languages, there is typically an issue when a legacy system or a quick RAD application needs to
access the same information. In addition, the OO databases haven’t made a large impact in the database
market; they’re still coming of age when compared to those offered by Oracle, Microsoft, and others.
Mapping
The three solutions we’ve just covered can work, but they present issue when put into the mix of legacy
applications and traditional relational database systems. If you’re working with an application that uses
a database, you’ll most likely need to use databases having names like Oracle, MySQL, Sybase,
Microsoft SQL Server, and others. These databases are based on the traditional relational model; some-
how we need to use them along with our Java objects.
An object can be placed in a relational database through the process of mapping. Mapping is a technique
that places an object’s attributes in one or more fields of a database table. For example, the earlier CD
3
Introduction to Mapping Objects to Relational Databases
03_576771_c01.qxd 9/1/04 12:09 PM Page 3