Tuesday, August 08, 2006

Importing Relational Databases into RDF/OWL using D2RQ

A common request from our customers is the ability to reuse existing (legacy) databases in the context of an RDF/OWL project. The mapping of relational databases into RDF is non-trivial and since I am not at all an expert on databases, I turned to the Web to find help. From some other entry on Planet RDF, I dimly remembered that Chris Bizer has been working on this, and linked from his pages I discovered D2RQ.

D2RQ is a mapping language formalized as an RDF/OWL model, i.e. you can use an OWL editor of your choice to edit which database table is mapped into which class, whether columns are treated as datatype properties or object properites etc. I very much like approaches that come with a clean RDF schema, so that much of the program logic can be expressed in terms of dynamic declarations without having to recompile any code. The perfect thing about D2RQ is that it also comes with an implementation of the mapping engine. This engine is written in Java for Jena and Sesame, and allows programmers to treat relational databases as virtual triple stores.

Well, since TopBraid Composer is based on Jena, this approach provides us with a perfect example of component reuse: Version 1.1.5 (out today) now comes with a feature to import relational databases using D2RQ. The manual describes details, but here is a screenshot of how databases can be displayed:

The picture above (click on it to see a full screen version) displays some instances that are directly taken from a MySQL database (not a triple store)! The projects consists of an umbrella ontology that imports a schema ontology (in OWL) and the virtual D2RQ graph. The D2RQ graph is instructed by a mapping ontology, and the mapping model itself can be edited with Composer as well. Since Composer treats the D2RQ graph just like any other triple store, it is possible to run SPARQL queries or perform reasoning on it. To keep things simple, D2RQ does not support write access to the database.

It is simply amazing how easy it was to integrate this component into the ontology editor. Once more the decision to use Jena as the foundation paid off.

We sincerely acknowledge Chris Bizer and his colleagues for this work and hope to collaborate on the future evolution of this neat library. Chris kindly allowed us to distribute their GPL library together with Composer even though Composer is a commercial product.


Post a Comment

<< Home