SPARQL to ignite web 2.0

Kendal Clark, managing editor of, just wrote: "SPARQL over AJAX just by itself is so cool it gives me a headache!". [0]

What problem does SPARQL solve? SPARQL is here to replace the SELECT part of SQL query statements, the long standing standard for database access. The problem with SQL queries is that in order to use it an application needs to know the internals of the database it is querying: the names of the tables, the name of the rows, what data is available in each of the rows, and what that data means. This makes it impossible to query database on the wild wild web. There is just too much setup that needs to be done. What does SPARQL add? Not much. But what it adds is essential: URIs. By using URIs to identify the data structures (ontologies) it becomes possible to escape from the little closed islands of each database, and query them in a global manner with a unified interface. The definition of the data structures can and is being developed worldwide in a distributed manner. Some popular ontologies such as Dublin Core, Foaf, DOAP, and many others are allready available, and many more are on their way. All a database will need to do is list the ontologies it exports to, and any application will be able to query it using those ontologies. Here is an example from the SPARQL spec.

PREFIX  dc:  ≤≥
PREFIX  ns:   ≤≥
SELECT  ?title ?price
WHERE   { ?x ns:price ?price .
          FILTER (?price ≤ 30) .
          ?x dc:title ?title . }
Here we are asking for all books with a price less than 30. The price ontology is made up, and a better one would clearly specify the currency. But that is enough to get an idea of the power of SPARQL. The same query could be run against amazon, e-bay or any other web vendor. The beauty is that none of them need to change the database they are using. They just need a conversion layer between the ontologies used and the database structure (be it an SQL or OO database, or even just flat files) they use. On the client side what is needed is just the equivalent of JDBC for SPARQL for each of the languages. Most language allready have a few frameworks that can deal with this.

So why would the database owners all come to agree to use the same ontologies? Well through similar standardisation processes as that used for Java with the JCP process. Plus the inevitable network effect. As popular clients come to use popular ontologies, services that provide their data using those ontologies will gain more customers, making those ontologies more popular. Conversion layers between ontologies are also very easy to write, are partly built in to OWL for example, so that any bumps on the road can easily be dealt with. Because a similar law applies to information as applies to network connectivity: The value of your data grows exponentially with the number of way you can combine it [2]. And combining data is exactly what the Semantic Web had been built to make possible.

[0] It also gives me a headache, but it my case I think it is more the AJAX bit that does it. The idea of my application having dependencies on browser versions and having to debug for each version is just too much for me to contemplate. But then I have never programmed an AJAX application - perhaps with the help of some good libraries these problems are not as as bad as I fear. I suppose I just love the Java guarantee of write once run anywhere. There is no denying though that AJAX applications are cool.
[1] I have to use ≤ and ≥ as there is a bug in my editor that won't let me use the less than and greater than signs
[2] see my post working with people


I have had it ALL in this short paper, what is not stated in most books. I.e what SPARQL can do and SQL cannot?


Posted by FHenry on May 30, 2008 at 06:38 AM CEST #

I wrote a short post recently that gives an example of how this can be used with DBPedia called "SPARQLing international calling codes" whose permalink is

Posted by henry Story on May 30, 2008 at 01:20 PM CEST #

Post a Comment:
Comments are closed for this entry.



« February 2016