W3C home > Mailing lists > Public > public-rdf-dawg-comments@w3.org > March 2012

Multiple BINDING clauses in SPARQL queries

From: Alexander Dutton <alexander.dutton@oucs.ox.ac.uk>
Date: Tue, 13 Mar 2012 09:13:43 +0000
Message-ID: <4F5F0FC7.20700@oucs.ox.ac.uk>
To: "public-rdf-dawg-comments@w3.org" <public-rdf-dawg-comments@w3.org>
Dear SPARQL-WG,

<http://www.w3.org/TR/sparql11-query/#sparqlGrammar> (rule 28) restricts
a SPARQL query to having only one BINDINGS clause. For brevity one might
wish to include more than one BINDINGS clause and have each of them joined.

This would allow queries such as:

CONSTRUCT WHERE {
  ?thing ?labelProperty ?label
} BINDINGS ?thing {
  (<http://id.example.com/thing/one>)
  (<http://id.example.com/thing/two>)
  (<http://id.example.com/goldfish>)
} BINDINGS ?labelProperty {
  (skos:prefLabel)
  (skos:altLabel)
  (skos:hiddenLabel)
  (dc:title)
  (dcterms:title)
  (rdfs:label)
  (foaf:name)
  (gr:name)
}

i.e. dig out a name for more than one resource at once, without knowing
which name properties are used.

While the BINDINGs could be joined together by the client, this would
lead to a large number of bindings to send for something that can easily
be calculated by the query engine.

The SPARQL grammar also forbids BINDINGS clauses on sub-selects, which
(as far as I can tell) makes a solution using sub-selects impossible.

Another solution would be to use a "FILTER (?labelProperty IN
(skos:prefLabel, skos:altLabel, …))", but this seems less easy to
optimise for, and less clear.

Using a property path (e.g. "?thing skos:prefLabel|skos:altLabel|…
?label") loses the detail of which property term was matched.

With kind regards,

Alexander

--
Alexander Dutton
Developer, InfoDev; data.ox.ac.uk, OxPoints
Oxford University Computing Services
Received on Tuesday, 13 March 2012 09:14:13 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 13 March 2012 09:14:13 GMT