|
Helping ordinary people create extraordinary websites! |
Make Database Queries Without the DatabaseBy Brian Goetz2005-07-14
My kingdom for a data model At this point, the lack of a formal data model, which describes the data gathered and against which you could more easily express selection and aggregation queries, was starting to look like a liability. Perhaps laziness was not as efficient as first hoped. But, while this application had no formal data model, maybe we could "borrow one" by streaming the data into an in-memory database and querying against that. Two possibilities immediately sprang to mind; HSQLDB, the open-source in-memory SQL database, and XQuery. I didn't need the persistence that a database offered, but I did want the query language. HSQLDB is an embeddable database engine written in the Java™ language. It has table types for both in-memory and disk-based tables, and was designed for being embedded entirely within an application, eliminating the administrative overhead associated with most real databases. To load the data into HSQLDB, it would only be necessary to write a Visitor that traversed the in-memory data structure and generated the appropriate INSERT statements for each entity to be stored. Then you could execute SQL queries against the in-memory database tables to do the reports and throw away the "database" when finished. Oops, forgot how annoying relational databases are Tutorial Pages: » Borrowing a data model can simplify development and enhance performance » No database needed » My kingdom for a data model » XQuery to the rescue » Summary » Resources First published by IBM developerWorks |
|