Implementing SPARQL with tolog

<< 2005-12-15 23:03 >>

I realized quite a while ago (a year ago, maybe) that it's possible to implement SPARQL on top of tolog without too much effort. Ontopia has never done anything about this since we have not seen any interest in this feature, but recently I got some questions about this, so I figured it might be worth writing up the basic idea.

The basics

So, given a SPARQL query, how can you execute that using tolog? The difficulty, of course, is that SPARQL operates on RDF, and tolog operates on Topic Maps. However, the RTM RDF-to-Topic Maps mapping enables us to deal with this. If we have an RTM mapping for the vocabulary that is being queried that gives us enough information to translate the SPARQL query into an equivalent tolog query, since the two languages are so similar.

The best way to see how it would work is to look at an example. Below is a very simple SPARQL query that finds the description of a particular book.

PREFIX  dc: <>
SELECT  ?desc
WHERE   { <> dc:description ?desc }

Given an RTM mapping that says dc:desc is an occurrence type, it's quite obvious how this should be translated into tolog. The equivalent tolog query would be:

USING dc FOR i""
SELECT  $desc
FROM    dc:description(i"", $desc)?

Basically, each triple pattern in the SPARQL query becomes a corresponding predicate in tolog, and the RTM mapping has enough information to tell us how to construct the predicate. In the case where the RDF property maps to an association type in Topic Maps we would even know the role types played by the subject and the object respectively.

Scaling up to larger queries

Of course, handling single-pattern queries isn't much of a feat, so for this to be useful we have to also be able to handle more complex queries. This turns out to be easy, however, as SPARQL is not a very big language, and what features it has maps very neatly onto corresponding tolog features.

The following can be handled without problems:

The features that might cause some difficulties are:

There might also be other stumbling blocks I haven't spotted yet, but this really does look like it's not that hard.

In addition, SPARQL supports producing several kinds of output from the query, but supporting these should not be hard:

Why do this?

You need more reasons beyond the fact that it's cool? :)

Well, the main reason to do this would be to allow a Topic Maps-based system to support the SPARQL protocol, which effectively means that you can play in an RDF environment even if you are using Topic Maps. The consequence is that you really can have true interoperability between Topic Maps and RDF.

Similar posts

Typed data in tolog

We've known for a long time that sooner or later we'd have to start supporting data types (numbers, dates, ...) in tolog, but so far we haven't done it

Read | 2006-05-10 23:17

tolog updates

The tolog query language has been around for a long time, but so far it only does querying, and not updates

Read | 2006-02-21 20:49

Semantic Web adoption and the users

A hot topic at ESWC 2013, and many other places besides, was the issue of Semantic Web adoption, which after a decade and a half is still less than it should be

Read | 2013-10-18 15:43


Javi - 2008-04-03 19:32:55

If you want a Tutorial of Tolog look at this

Add a comment

Name required
Email optional, not published
URL optional, published
Spam don't check this if you want to be posted
Not spam do check this if you want to be posted