The article Why Migrate to the Semantic Web
described the benefits of the semantic web for applications that deal with real world objects. It outlined how an
existing web application (
CDMS) that stored its data in a relational database now has added benefits as a semantic web application.
As part of the process of migrating to the semantic web, you need to select components that form the core of the semantic web framework. This article outlines the foundations of the application and defines its overall structure.
Requirements of a Semantic Web Framework
For the CDMS application, the main requirements of a semantic web framework include:
Selecting a Java Semantic Web Framework
- Core support for RDF,
the RDF Schema language (RDFS), and the
Web Ontology Language (OWL).
- Support for the current SPARQL specification, including the ability to easily query external datasets for related items.
- Support for SPARQL Extensions such as count, insert, update, and delete.
- Support for transactions because RDF data will be inserted, updated and deleted; possibly in conjunction with updating relational data.
- Ability to scale efficiently to large datasets.
- Ability to deploy Linked Data using the methods outlined in
the tutorial How to Publish Linked Data on the Web, e.g., appropriately handling content negotiation.
- Select apply-role based security to publish Linked Data, e.g., for project collaboration scenarios when sharing data externally with project partners.
- Provide inference capabilities for OWL ontologies.
A number of good
semantic web development tools
are available, in several different programming languages, but for this application the selection is limited to Java
based tools. This is because the existing application is written in Java and it is intended to continue using parts of
its persistence layer (
MySQL) in areas not suited to the semantic web.
Based on their known scalability features (as per the Berlin SPARQL Benchmark), the prime candidates were :
Jena was selected as the main component for this semantic web framework for the following reasons.
- Jena SDB uses MySQL for the storage of RDF datasets, simplifying integration with the existing MySQL relational database.
- Jena ARQ provides a leading implementation of SPARQL, including SPARQL Extensions such as count, insert, update, and delete.
- Jena includes Joseki as an HTTP engine that supports the SPARQL Protocol and the SPARQL RDF Query language. The query engine is based on ARQ. Joseki can also be deployed to Tomcat.
- Pellet can be added as an external OWL-DL reasoner.
A number of other open source projects provide additional useful functionality for Jena, such as Jenabean and Jfresnel.
Additional framework components:
Laying the Foundations of the Application
- Jersey (which is the reference implementation of JAX-RS) was selected to implement RESTful web services, as part of providing Linked Data.
- The Spring framework and Spring Security were chosen to apply role-based security to the RESTful web services.
The main steps in laying the foundations of the application are:
Installing Jena SDB
- Installing Jena SDB to store RDF data. This includes populating the SDB with some initial data to confirm the install.
- Creating a Maven-based web application project that integrates Jena SDB with Joseki, providing a SPARQL end point for querying the RDF data held within Jena SDB.
Follow these steps to install the Jena SDB:
- Download and install MySQL if it is not already installed.
- Download Jena SDB 1.1 then use the following steps to install it within MySQL as per the instructions on the wiki.
- In MySQL create a database named "sdb", specifying utf8,
mysql> create database sdb character set utf8 ;
- Set up a store description sdb.ttl similar to the SDB example, but with MySQL specifics based on
the file SDB-1.1/Stores/sdb-mysql-innodb.ttl found in the SDB distribution, and a database name of
"sdb". The other change is to set the sdb:layout to "layout2/index". The index
layout ("layout2/index") usually loads faster than the hash form.
(sdb.ttl is provided in the attached source code in the
- Set up the environment variables listed in the SDB Commands script setup section.
Run the create command to create the tables within the sdb database
SDBROOT > bin/sdbconfig -sdb=sdb.ttl -create
- Run the test suite: SDBROOT > bin/sdbtest --sdb=sdb.ttl testing/manifest-sdb.ttl
If any tests fail, check the Mysql Notes. Some additional steps to
set up utf-8
may be required.