Abstract. This document lists a selection of queries that have been used in the discussions of the RDF Data Access Working Group.
Version 0.3, 23-06-2004
The queries are given in an abstract query syntax, listing triples with variables to be bound and qnames. These triples that match a subgraph of the RDF graph to be queried and are listed, followed by and constrinats that apply to the variables. Variables are prefixed by the ? character.
Discussed at the 1st face to face meeting.
This query highlights the difference in execution-complexity between two superficially similar queries.
In this query the number of possbile matches for the constraint section gorws with |?x| × |?y| whereas with a fixed operand (as in ?xAge < 18) the number of possible matches grows with |?x|.
?x :marriedTo ?y
?x :age ?xAge
?y :age ?yAge
?xAge < ?yAge
From http://lists.w3.org/Archives/Public/public-rdf-dawg/2004AprJun/0630.html
Demonstrates disjustion operation
A0 p1 B
A1 p2 C
A2 p3 D
A3 p2 C
A3 p3 D
?n p2 C || ?n p3 D
A1 p2 C
A2 p3 D
A3 p2 C
A3 p3 D
From http://lists.w3.org/Archives/Public/public-rdf-dawg/2004AprJun/0598.html
Demonstrates possible results for nested optional subgraphs.
A p1 B # truncates on optional 1 term 1
A p2 C
A2 p1 B # truncates on optional term 2
A2 p2 C
A2 p3 D2
D2 p4 E2
A3 p1 B # eliminates second optional
A3 p2 C
A3 p3 D3
D3 p4 E3
D3 p5 F3
A4 p1 B # has all arcs
A4 p2 C
A4 p3 D4
D4 p4 E4
D4 p5 F4
D4 p6 F4
(~ indicates optional subgraph)
?n p1 B
?n p2 C
~(?n ?p3 ?d
?d p4 ?e
?d p5 ?f
~(?d p6 ?g))
+----------+----------+----------+----------+----------+
| n| d| e| f| g|
+----------+----------+----------+----------+----------+
| A| NULL| NULL| NULL| NULL|
| A2| NULL| NULL| NULL| NULL|
| A3| D3| E3| F3| NULL|
| A4| D4| E4| F4| F4|
+----------+----------+----------+----------+----------+
Demonstrates possible bindings for queries containing optional components. From http://lists.w3.org/Archives/Public/public-rdf-dawg/2004AprJun/0652.html
:x :p :a
:x :q :b
[] indicates optional triples
[(:x :p ?v)]
[(:x :q ?v)]
+--------+
| v |
+--------+
| :a | matches the first part but then the second can't match
| :b | matches the second part but not the first
+--------+
[(:x :p ?v)
(:x :q ?v)]
has no match
Demonstrates simple, partial matching case. From http://lists.w3.org/Archives/Public/public-rdf-dawg/2004JulSep/0044.html.
http://jena.hpl.hp.com/~afs/DAWG/Tests/dawg-data-01.n3
http://jena.hpl.hp.com/~afs/DAWG/Tests/dawg-query-001 (BRQL syntax)
(?person foaf:name ?name)
[(?person foaf:mbox ?mbox)]
http://jena.hpl.hp.com/~afs/DAWG/Tests/dawg-result-001.n3
+-------------------------------+
| name | mbox |
+-------------------------------+
| "Bob" | <mailto:bob@work> |
| "Bob" | <mailto:bob@home> |
| "Eve" | null |
| "Alice" | <mailto:alice@work> |
+---------+---------------------+
Demonstrates multi-triple graph pattern in optional part. This leads to a need for nested optionals: get the name or mbox of any people known by people in the FOAF datafile. From http://lists.w3.org/Archives/Public/public-rdf-dawg/2004JulSep/0044.html.
http://jena.hpl.hp.com/~afs/DAWG/Tests/dawg-data-01.n3
http://jena.hpl.hp.com/~afs/DAWG/Tests/dawg-query-002 (BRQL syntax)
(?person foaf:name ?name)
[(?person foaf:knowns ?p2)
(?p2 foaf:name ?name2)]
http://jena.hpl.hp.com/~afs/DAWG/Tests/dawg-result-002.n3
+---------+-----------+
| name | name2 |
+---------+-----------+
| "Bob" | "Alice" |
| "Alice" | "Bob" |
| "Eve" | null |
+---------+-----------+
Demonstrates multiple, independent optional clauses. From http://lists.w3.org/Archives/Public/public-rdf-dawg/2004JulSep/0044.html.
http://jena.hpl.hp.com/~afs/DAWG/Tests/dawg-data-01.n3
http://jena.hpl.hp.com/~afs/DAWG/Tests/dawg-query-003 (BRQL syntax)
(?person rdf:type foaf:Person)
[(?person foaf:name ?name)]
[(?person foaf:mbox ?mbox)]
http://jena.hpl.hp.com/~afs/DAWG/Tests/dawg-result-003.n3
+-----------+---------------------+
| name | mbox |
+-----------+---------------------+
| "Bob" | <mailto:bob@home> |
| "Bob" | <mailto:bob@work> |
| null | <fred@edu> |
| "Eve" | null |
| "Alice" | <mailto:alice@work> |
+-----------+---------------------+