Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Create Scalable Semantic Applications with Database-Backed RDF Stores

Store your RDF triples in a database for faster performance and greater scalability.

hope you've been following the growing interest in semantic technology and reading the articles on DevX's Semantic Zone, and feel ready to try out semantic technologies in your own applications. If so, you might have obtained a moderately sized RDF dataset from your domain and eagerly cranked out some simple code such as the following, which loads the freely available National Cancer Institute's (NCI) cancer ontology using the Jena API:

Model model = ModelFactory.createDefaultModel(); model.read(getClass().getResourceAsStream( "/nciOncology.owl"), "http://www.mindswap.org/2003/nciOncology.owl#");

NCI's cancer ontology file is only about 32 MB in size, so you might be a little startled after a few seconds when the Java VM throws an error:

java.lang.OutOfMemoryError: Java heap space

The small size of the ontology file belies the fact that it contains almost half a million statements. Yes, you could start tuning your VM settings so Java could manage the ontology completely in memory—but that approach won't scale as you work with more and bigger ontologies. In addition, the significant start-up time involved in parsing so many statements leaves a lot to be desired.

A more practical approach is to store larger ontologies in a database-backed RDF store (referred to here as an RDF database for brevity), and then query the model much as you would a database. This article shows you how to do just that, with the goal of pointing out several technologies that you can use independently or in combination to accomplish such queries. The article will then take a deeper dive using one specific option, providing more detailed examples that show you how to use the Jena API to manage and query Jena-based RDF databases. If you're not already familiar with concepts and tools such as RDF, SPARQL, and Jena, the resources you'll find at the end of this article should help.

To illustrate Jena's support for working with database-backed RDF stores, you'll see how to create a graphical management tool for Jena RDF databases and models, the "Jena Database Model Manager," which is simply an SWT-based wrapper for the Jena APIs.

Author's Note: I won't explore the SWT code here, but you can find it in the downloadable source code that accompanies this article. Figures 1, 2, and 3 show the Jena Database Model Manager in action.

Figure 1. Jena Database Connection Management: Users create named connections to Jena databases to which they can then connect and disconnect.
Figure 2. Jena Model Management: The tool provides a graphical approach toward creating, deleting, and loading Jena Models.
Figure 3. Querying a Jena RDF Database: The Query tab allows SPARQL queries to be executed against one or more Jena models.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date