W3C home > Mailing lists > Public > www-rdf-rules@w3.org > February 2003

RE: RDF query testcase requirements: IRC chat?

From: Jos De_Roo <jos.deroo@agfa.com>
Date: Sun, 16 Feb 2003 20:34:04 +0100
To: Andy_Seaborne@hplb.hpl.hp.com
Cc: "'Libby Miller'" <Libby.Miller@bristol.ac.uk>, www-rdf-rules@w3.org, www-rdf-rules-request@w3.org
Message-ID: <OF692774C1.0D5BCF62-ONC1256CCF.006B054A-C1256CCF.006B8ADF@agfa.be>

Andy et all.,

Suppose a query is an RDF graph
and the results are proofs given with --think
then it is indeed valuable to see in those proofs
the explanation of the substitutions that were made.

For example

==== testP
@prefix : <test#>.

:a :b :c.
:d :c :f.
:g :c :i.

queried with

==== testC
@prefix : <test#>.

_:x :b _:u.
_:y _:u _:z.

would then (according to our latest tests) result in

==== testR
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix : <test#>.

{_:x_3 = :a. :b = :b. _:u_3 = :c. _:x_3 :b _:u_3} log:implies {:a :b :c}.
{_:y_3 = :d. _:u_3 = :c. _:z_3 = :f. _:y_3 _:u_3 _:z_3} log:implies {:d :c

{_:x_3 = :a. :b = :b. _:u_3 = :c. _:x_3 :b _:u_3} log:implies {:a :b :c}.
{_:y_3 = :g. _:u_3 = :c. _:z_3 = :i. _:y_3 _:u_3 _:z_3} log:implies {:g :c

There's still no result grouping though...

-- ,
Jos De Roo, AGFA http://www.agfa.com/w3c/jdroo/

                    "Seaborne, Andy"                                                                                      
                    <Andy_Seaborne@hplb.h       To:     "'Libby Miller'" <Libby.Miller@bristol.ac.uk>,                    
                    pl.hp.com>                   www-rdf-rules@w3.org                                                     
                    Sent by:                    cc:                                                                       
                    www-rdf-rules-request       Subject:     RE: RDF query testcase requirements: IRC chat?               
                    2003-02-15 09:58 PM                                                                                   

Libby wrote:
> The main issue for me is how to express the query itself.
> My inclination is to try and express queries as graphs with parts
that > is, to interpret an RDF graph as a query, as Jos de Roo suggested
> I think this would give us one big win, which is that we could ignore the
> syntactic differences between several very similar query languages for
> (although this will by no means encompass all RDF query languages). Plus
> course, we get the query parser for free.

Following on from Jos's message[1], I wrote the query in cwm/N3 and
the result set bindings as RDF.  (The result set vocabulary is given at [2]
and is unfinished.)  Encoding the result set in RDF does have the feature
that we can merge it with the testcase RDF and annotate it.  Use in a real
application is more limited as the application is going to have to process
the output graph again when (as Geoff notes) it wants the SELECT variables
or it wanted the matching subgraph, in which case the application is going
to substitute the bindings back into the query.

Using the example taken from Jos's message: (all files are attached for
convenience and in case this email gets reformatted):

Data set:
data.n3 ---------------------------------
@prefix : <http://example.com/> .
:a :b :c.
:d :c :f.
:g :c :i.

Encoded for cwm:
query.n3 --------------------------------
@prefix rs:   <http://somewhere/2003/01/result-set-vocab#> .
@prefix ex: <http://example.com/> .

{ ?x ex:b ?u .
  ?y ?u [] . }
  <> rs:hasSolution
         rs:hasBinding [ rs:variable "u" ; rs:value ?u ] ;
         rs:hasBinding [ rs:variable "y" ; rs:value ?y ]
} .

which uses a bNode [] for a "don't care" slot in the triple pattern (was
?z).  The output is a series of variable bindings for ?u and ?y (?x is not
selected - could be replaced by another []) according to the result set
vocabulary.  We give the template for one row of the result table; multiple
occurences of this get generated by the formula matching several times. The
RDF produced encodes a result set - a number of solutions, provided by the
bindings.  The RDF produced is a bit rough-and-ready as it does not record
the data source or some other details in the vocabulary.

So running the query with cwm (cwm 1.126)
  cwm data.n3 -filter=query.n3 > result-set
and then tidying the results into

result-set-tidy ------------------------
@prefix rs: <http://somewhere/2003/01/result-set-vocab#> . @prefix ex:
<http://example.com/> .

  rs:hasSolution  [
      rs:hasBinding  [ rs:value ex:c; rs:variable "u" ] ;
      rs:hasBinding  [ rs:value ex:g; rs:variable "y" ]
                  ] ;
  rs:hasSolution  [
      rs:hasBinding  [ rs:value ex:c; rs:variable "u" ] ;
      rs:hasBinding  [ rs:value ex:d; rs:variable "y" ]

which uses rs:variable to quote the variable.  Substituting this back into
the original query gives the ways the pattern matched the graph.  Merging
all these gives the smallest subgraph of the original graph that generates
the same answers.

To check the tidying: compare the two graphs with:
  jena.rdfcompare result-set result-set-tidy N3 N3
  models are equal (i.e. isomorphic structures)

For comparison: the RDQL query on data set data.n3:
    SELECT ?u ?y
    FROM <data.n3>
    WHERE (?x ex:b ?u) (?y ?u ?z)
    USING ex FOR <http://example.com/>

u                      | y
<http://example.com/c> | <http://example.com/d>
<http://example.com/c> | <http://example.com/g>


[1] http://lists.w3.org/Archives/Public/www-rdf-rules/2003Feb/0003.html
[2] http://lists.w3.org/Archives/Public/public-esw/2003Jan/0046.html

(See attached file: data.n3)(See attached file: query.n3)(See attached
file: result-set)(See attached file: result-set-tidy)

Received on Sunday, 16 February 2003 14:35:10 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 2 March 2016 11:10:14 UTC