|
SYS-CON.TV Webcasts
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
Top Links You Must Click On
Product Reviews FirstSQL/J Professional v2.0
by FirstSQL
FirstSQL/J Professional v2.0
by FirstSQL
By: Paul Gifford
May. 1, 2003 12:00 AM
Pop quiz: you're writing a standalone cross-platform application that needs to handle a large number of data files. The data may be disparate in type but it has some qualities in common. You want the user to be able to browse or search the data and, of course, you want your application to be responsive. What are some possible ways to handle the data? The most rudimentary would be to allow the user to specify the location of the data files and have the application search those files each time the user needs data, much like a file finder may search for text in a file. A slightly more elegant and faster method would be to create a file containing information about the data files; this metadata could then be searched to locate the correct data file. This is reasonably easy to implement, but complex queries are difficult to perform and adding support for future data types or additional parameters requires careful coding. The most powerful solution would be to store the metadata in a relational database. A well-designed database offers flexibility, speed, and easy data manipulation through JDBC support. This database must be 100% Java to maintain the cross-platform compatibility as well as be easy to use so the average Java programmer can integrate it with little difficulty. FirstSQL provides such a database in FirstSQL/J Professional.
FirstSQL/J Professional v2.0 The recently released version 2 adds support for an in-memory mode of operation that keeps tables in memory for faster access, writing them to disk at the end of a database run. FirstSQL/J Professional also optimizes complex queries and efficiently handles deeply nested queries.
Installing and Using FirstSQL/J Professional Adding FirstSQL/J Professional to an application is as easy as including a JAR file in the application's classpath and pointing to a database. FirstSQL/J Professional doesn't support runtime creation of databases, so a new database must be created using the included utility or the empty database installed with the product must be copied. From there it's just a matter of manipulating the database with SQL statements or FirstSQL extensions.
Real-World Use While an RDBMS (one that does not support objects in the database) would suffice, we felt embedding objects directly in the database would add considerable power and flexibility. For example, consider a spatial query. The user wants to show all the available satellite imagery containing a specific latitude and longitude point (see Figure 3). Without objects, the bounds of each image have to be stored as four columns in a table, one column for each corner point. A very complex query or iteration over the whole dataset would be necessary to determine if the desired point fell within the bounds of the image. Our solution was to create a bounds object consisting of the corner points and comparison methods such as a point within the bounds, an area contained within the bounds, and an area intersecting the bounds. The following snippet of SQL illustrates how the object was used.
WHERE(img.sat_image_bounds).containsPoint The method returns an integer because a method in a SQL must have arguments and a return type that are convertible to a SQL data type or be a user-defined class, and BOOLEAN is not a supported data type. To define a class for use by the database is equally simple. Here's the entire SQL statement to register a class for use by the database: CREATE CLASS geobounds FROM 'com.directmet.geo.GeoBounds' This ease of use fulfilled one of the requirements I had in selecting a database: easy to implement. I have a working familiarity with SQL and relational database design though I'm not an expert by any means. Another requirement was speed. While FirstSQL provides benchmark code, huge numbers of INSERTs and SELECTs alone are not representative of the type of query our database would most often see. I anticipated spatial queries against objects in the database would be the most common and potentially the most time-consuming. I wrote a short program to fill a table with an object representing geographic bounds and containing methods to compare against those bounds, then ran queries against the table calling the methods in the stored objects. Performance was good enough so that the database would not be the source of delays affecting the user's experience. Using the in-memory mode improved performance several fold. FirstSQL/J Professional held up well through development and testing under both Windows and OS X. Through many crashed applications no data was ever lost, even when the problem occurred in code related to the database, nor was the database ever left in an invalid state. FirstSQL provides a short block of code to recover after an abnormal program termination, so all that's required to maintain a healthy database is to run the recovery code if the program did not exit gracefully.
Deployment
Support
Summary SIDEBAR
FirstSQL, Inc.
Specifications
Test Platform
Processor: Apple iMac G3 500MHz SIDEBAR
Product Snapshot Reader Feedback: Page 1 of 1
Enterprise Open Source Magazine Latest Stories . . .
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||