Berkeley DB adds XML smarts
Sleepycat’s Berkeley DB XML database library combines sturdy Berkley DB engine with XML doc management
Because Berkeley DB XML manages documents, you would expect it to allow you to attach information that isn’t in the document’s content. Berkeley DB XML meets those expectations by allowing you to attach metadata in a clever way that leaves the document’s content unmolested.
When you define metadata for a document, the engine “reflects” that metadata as attributes into the document’s root element: From the query’s perspective, the metadata name/value pairs are simply XPath-queryable tag attributes.
But that perspective is an illusion — the document’s contents are unchanged. The attributes have actually been “snuck in” by the engine for the benefit of the query, so you can search for attributes without having to use a special syntax.
Berkeley DB XML’s processing of a whole XML document as a single unit does create some side effects in the way documents are accessed. As you might imagine, you cannot delete portions of a document; you can only delete the whole thing. Consequently, modifying or deleting part of an XML document is really an update operation, and an update can only be done by reading the old document, modifying it in memory, deleting its image from the container, then re-storing the updated version.
Happily, Berkeley DB XML provides an update method that does all this dirty work for you invisibly. But if your application employs transactions or locks, you have to keep in mind that lock granularity is at the document level. It’s not possible, for instance, to lock an element within an XML document. This could affect performance if you craft an app such that a lot of locking is going on and users hold each other up.
Possibly the greatest benefit of Berkeley DB XML is its masking of the Berkeley DB system complexity so that a programmer can easily add XML database capabilities to an application. Berkeley DB XML “pre-tweaks” Berkeley DB parameters for you, so you can go straight on to programming your app.
But while it hides these details, it does not make them unreachable. If you want to crawl under the hood and retune some of Berkeley DB’s parameters, you can. In fact, because all the source code is provided, if you want to crawl under the hood and reverse-engineer the entire engine, you can do that, too.
Berkeley DB XML’s real power is its foundation: The Berkeley DB system is fast and rock-solid. Even better, all the extensions available to Berkeley DB are instantly available to a Berkeley DB XML application. With free availability on a single-site installation, plenty of examples, and source code, how can you go wrong?
The only thing I missed in Berkeley DB XML was some sort of query console so that I could easily experiment with XPath queries and view the results. A Sleepycat engineer told me that, in the next release, they are providing a written sample that would incorporate many of the features of a query console. I can’t wait.
Read more about data management in InfoWorld's Data Management Channel.