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

Re: WHERE clause optional?

From: Graham Klyne <gk@ninebynine.org>
Date: Fri, 08 Apr 2005 15:17:25 +0100
Message-Id: <>
To: Dave Beckett <dave.beckett@bristol.ac.uk>
Cc: public-rdf-dawg-comments@w3.org

At 13:30 08/04/05 +0100, Dave Beckett wrote:

>On Fri, 08 Apr 2005 12:41:34 +0100, Graham Klyne <gk@ninebynine.org> wrote:
> >
> > In:
> >    http://www.w3.org/TR/2005/WD-rdf-sparql-query-20050217/
> >
> > the syntax indicates the WHERE clause is optional (production [1]), but I
> > can't find any indication of what is returned when no WHERE clause is
> > provided.  Maybe it's there somewhere; if so, lacking a single
> > comprehensive description of the WHERE clause, it is difficult to find it.
>I can't really answer since I'm also curious where WHERE is optional, but
>this could be a legal sparql "query" with no where:
>   prefix ex: <http://example.org/>
>   construct { ex:a ex:b ex:d }
>as it's mostly a way to generate a graph; so a result is returned.

Hmmm, maybe.  Let me expand a little:  I see my query processor working 
something like this:

   Locate graph(s) to query
   >> match query pattern against graph
   >> construct desired result from match (per SELECT/CONSTRUCT/ASK)

The result of the second step is, I think, a collection of variable 
bindings and a set of triples used for each.  The CONSTRUCT clause is 
applied for each member of this collection.  Now, if there is no pattern to 
match, how many times is it matched?  For your interpretation to work under 
this regime, it must be at least once or the result graph would be empty.

One alternative is that a null pattern matches *any* graph, so there may be 
an arbitrary number of matches (number of permutations of triples in the 
queried graph (or number of subgraphs), I suggest), but the result is still 
as you say because each match generates the same result and a graph is a 
_set_ of triples.  This works, but it feels a bit messy to me.

But that's not consistent, or a non-null pattern would match for each 
subgraph of the original that it matches.  Observing that (with a non-null 
pattern) every triple of a matched subgraph is used for each match 
generated, so a null pattern would exactly match a null subgraph, and every 
graph has exactly one null subgraph, so the null pattern would consistently 
match any graph exactly once.  This sits nicely with your example.

A consequence of this would be that:
   prefix ex: <http://example.org/>
always returns the value True.


BTW, I see you use lowercase in your SPARQL examples:  keywords are all 
uppercase in the grammar -- are they meant to be case-insensitive?  I can't 
find anything in the spec to tell me about this.


Graham Klyne
For email:
Received on Friday, 8 April 2005 14:18:26 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:52:06 UTC