W3C home > Mailing lists > Public > www-rdf-interest@w3.org > February 2004

RDFQ: RDF Query in RDF

From: <Patrick.Stickler@nokia.com>
Date: Thu, 26 Feb 2004 06:25:30 +0200
Message-ID: <A03E60B17132A84F9B4BB5EEDE57957B02A2E97B@trebe006.europe.nokia.com>
To: <www-rdf-interest@w3.org>

Howdy folks,

As fodder for the coming discussions in Cannes regarding DAWG and
related issues,  I wanted to draw attention to the latest specification of RDFQ [1]
an RDF vocabulary and query model for expressing queries and query results
in RDF.

RDFQ supports both query-by-example like templates, returning descriptions
of the matched resources, as well as SELECT like queries, returning variable
bindings using the Result Set Vocabulary [2].

E.g. Here is a query to identify all resources where their dct:modified timestamp 
occurs between  the specified timestamps (match exclusive), which will return
the concise bounded description of each matched resource: 

In minimal Turtle form (with RDFQ as default namespace and RDFS closures):

[:target [dct:modified [:gt "2001-08-11T10:30:00Z"^^xsd:dateTime;  :lt "2002-02-28T20:45:00Z"^^xsd:dateTime]]].

which in full Turtle equates to:

[a rdfq:Query;
      [a rdfq:Target;
             [a rdfq:Value;
                rdfq:gt "2001-08-11T10:30:00Z"^^xsd:dateTime;
                rdfq:lt "2002-02-28T20:45:00Z"^^xsd:dateTime

which in RDF/XML equates to:

               <rdfq:gt rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2001-08-11T10:30:00Z</rdfq:gt>
               <rdfq:lt rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2002-02-28T20:45:00Z</rdfq:lt>

Here is a query to identify all resources having a dc:title defined, returning the variable 
bindings for 'target' and 'title' for each matched resource: 

[:select ("target", "title"); :target [:id "target"; dc:title [:id "title"]]].


[a rdfq:Query; rdfq:select ("target", "title");
   rdfq:target [a rdfq:Target; rdfq:id "target"; dc:title [a rdfq:Value; rdfq:id "title"]]].


               <rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>

Which correlates to

SELECT ?target, ?title
WHERE {dc:title, ?target, ?title};

The generic selection query to obtain all statements in a knowledge base

SELECT ?subject ?predicate ?object 
WHERE {?predicate, ?subject, ?object};

would be expressed in RDFQ as

[:select ("subject", "predicate", "object");
 :target [:id "subject"; :property [:id "object"; :predicate [:id "predicate"]]]].

(note that encoding the query in RDF requires the predicate variable
to be defined in terms of the object for each property:value pair)

The RDFQ spec includes numerous additional examples.

One of the key benefits of RDFQ is that it is pure RDF. Both queries and results
are RDF, which means that only one parser is needed and one can employ RDF
tools and methods on the queries and results. Furthermore, auxiliary information
can be included in the request input, allowing e.g. the requesting agent to provide
vocabulary relations (e.g. rdfs:subPropertyOf, owl:sameAs) between common and
local terms so that  execution of the query can be optimized for that agent without
affecting the server's own knowledge base.

Using a keyboard-friendly serialization of RDF such as Turtle, where the RDFQ
namespace is default and RDFS closures for RDFQ terms are applied, queries are 
as concise and easy to express as most SQUISH like queries, as the examples
should illustrate.

The open source release of the Nokia Semantic Web Server [3] has some initial
support for RDFQ, which should become complete in the very near future.

Anyway, just wanted to give a heads up about RDFQ in case folks find it useful
input to next week's discussions.



[1] http://sw.nokia.com/rdfq/RDFQ.html
[2] http://www.w3.org/2003/03/rdfqr-tests/recording-query-results.html
[3] http://sw.nokia.com/tools


Patrick Stickler
Received on Wednesday, 25 February 2004 23:25:42 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:07:49 UTC