W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > April to June 2005

evaluating SPARQL w.r.t an RDF query language survey

From: Dan Connolly <connolly@w3.org>
Date: Tue, 05 Apr 2005 23:00:53 -0500
To: RDF Data Access Working Group <public-rdf-dawg@w3.org>
Message-Id: <1112760053.15073.524.camel@localhost>

A comment asks...
"How many of the 14 test questions in [1] does the current SPARQL spec
cover ?"
 --
http://lists.w3.org/Archives/Public/public-rdf-dawg-comments/2005Apr/0005.html
 -> http://www.aifb.uni-karlsruhe.de/WBS/pha/rdf-query/

I'm interested to take a crack at it, but I'd like some confirmation
from other WG members that I've got this right before I reply.
Perhaps it's worth making these into test cases...

I'm using http://sparql.org/query.html to test/develop these...

1 Path Expression
Return the names of the authors of publication X.

(This example seems to be more of a test for
collection/container access than #9)


prefix sam:
<http://www.aifb.uni-karlsruhe.de/WBS/pha/rdf-query/sample.rdf#>
SELECT ?result WHERE  
     { ?y sam:author ?z.
      ?z ?p ?x.
      ?x sam:name ?result.
     }

or, to be a bit more path-like...

prefix sam:
<http://www.aifb.uni-karlsruhe.de/WBS/pha/rdf-query/sample.rdf#>
SELECT ?n WHERE  
     { ?y sam:author [ ?li [ sam:name ?n] ].
     }


2 Optional Path
Return the name and, if known, the e-mail of the author of publication
X.

prefix sam:
<http://www.aifb.uni-karlsruhe.de/WBS/pha/rdf-query/sample.rdf#>
SELECT ?n ?addr WHERE  
     { ?y sam:author [ ?li ?who ].
       ?who sam:name ?n.
       OPTIONAL { ?who sam:email ?addr }
     }



3 union
Return the labels of all topics that and (union) the titles of all
publications.

prefix sam:
<http://www.aifb.uni-karlsruhe.de/WBS/pha/rdf-query/sample.rdf#>
prefix acm: <http://daml.umbc.edu/ontologies/topic-ont#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?label ?title WHERE  
     { { [] a acm:Topic; rdfs:label ?label }
     UNION
      { [] sam:title ?title }}


4 difference
Return the labels of all topics that are not titles of publications.

I can imagine some contortion using bound() and OPTIONAL,
but I can't figure it out, and I wouldn't expect the average
user to be able to.


5 Quantification
Return the persons who are authors of all publications.

nope.

The langauges with "yes" in this column seem to
support closed-world assumptions that
we don't support in SPARQL.


6 Aggregation
Count the number of authors of a publication.

nope.

unique names assumption.


7 Recursion
Return all subtopics of topic "Information Systems", recursively.

not directly, but if you layer SPARQL on top of
a system with inference, this can work.


8 Reification
Return the person who has classified the publication X.


prefix sam:
<http://www.aifb.uni-karlsruhe.de/WBS/pha/rdf-query/sample.rdf#>
prefix acm: <http://daml.umbc.edu/ontologies/topic-ont#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dc: <http://purl.org/dc/elements/1.1/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT ?who WHERE
{
  [ rdf:subject ?work;
    rdf:predicate sam:isAbout;
    rdf:object ?topic
  ] dc:creator ?who
}



9 Collections and Containers
Return the first author of Publication X.

(That's not a very good test for collections/containers.
It's easy to do in SPARQL, though...)

prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix sam:
<http://www.aifb.uni-karlsruhe.de/WBS/pha/rdf-query/sample.rdf#>
SELECT ?n WHERE  
     { ?y sam:author [ rdf:_1 [ sam:name ?n] ].
     }



10 Namespace
Return all resources whose namespace starts with
"http://aifb.uni-karlsruhe.de/".

seems to have a typo in the question...
missing www.

select ?R where
 { ?R ?x ?y.
   FILTER regex(str(?R), "http://www.aifb.uni-karlsruhe.de/")
}


hmm... why is [] no good? sparqler complains about...
select ?R where
 { ?R [] [].
}

I have only matched things that occur in the subject position.
I think I could use UNION to be more comprehensive, but that
seems beside the point of the test.


11 Language
Return the German label of the topic whose English label is "Database
Management".

prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?de WHERE
{
  [ rdfs:label ?de, "Database Management"@en ].
  FILTER lang(?de) = "de"
}


12 Lexical Space
Return all publications where the page number is the lexical value '08'.

prefix sam: <http://www.aifb.uni-karlsruhe.de/WBS/pha/rdf-query/sample.rdf#>
SELECT ?PUB WHERE {
  ?PUB sam:pages "08"
}


13 Value Space
Return all publications where the page number is the integer value 8.

prefix sam: <http://www.aifb.uni-karlsruhe.de/WBS/pha/rdf-query/sample.rdf#>
PREFIX xsd:    <http://www.w3.org/2001/XMLSchema#>
SELECT ?PUB WHERE {
  ?PUB sam:pages ?n.
  FILTER xsd:integer(?n) = 8
}


14 Entailment
Return all instances of that are members of the class Publication.

not directly, but like 7, if the background graph is supplemented
by inference, it becomes straightforward.


-- 
Dan Connolly, W3C http://www.w3.org/People/Connolly/
D3C2 887B 0F92 6005 C541  0875 0F91 96DE 6E52 C29E
Received on Wednesday, 6 April 2005 04:00:55 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:15:23 GMT