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

Re: Optional WHERE and WHERE {}

From: Seaborne, Andy <andy.seaborne@hp.com>
Date: Thu, 21 Apr 2005 21:03:28 +0100
Message-ID: <42680710.2060605@hp.com>
To: Dave Beckett <dave.beckett@bristol.ac.uk>
Cc: 'RDF Data Access Working Group' <public-rdf-dawg@w3.org>



Dave Beckett wrote:
> Question: Is the WHERE {...} structure optional in sparql?
> 
> The grammar says yes and lookin in the WD I can see it's given as an
> example with ASK,
> 
> So whereas CONSTRUCT, DESCRIBE and SELECT are all given examples
> requiring WHERE { .... },  ASK has the format ASK { ...} and no WHERE.
> Possibly ASK WHERE { ... } would be more consistent.

[1] Query  	  ::=    Prolog
                         ( SelectClause | ConstructClause |
                           DescribeClause | AskClause )
                         DatasetClause?
                         WhereClause?
                         OrderClause?
                         LimitClause?
                         OffsetClause?

so the whole clause is optional and not related to which kind of query it is.

e.g. DESCRIBE <uri>
CONSTRUCT { :a :b :c }

and also:

[13] WhereClause  	  ::=    	'where'? GraphPattern

so the WHERE keyword is optional.

These are both legal.

SELECT * WHERE { ?x ?y ?z }
SELECT * { ?x ?y ?z }

We could have different rules for presence/absence for each query type but at 
the moment it is symmetrical.

> 
> So thinking further, what does WHERE with an empty graph pattern {}
> mean?  I discussed this with EricP in Italy and we think it's the
> same as query succeding and returning 1 result, and it's what Algae2
> does.

Yes - it's a graph pattern that matches any graph.

> 
> Going through the query verbs:
> 
> 1. SELECT * WHERE {}
>   returns 1 result[row] with no bindings
> 
> 2. CONSTRUCT { :a :b :c } WHERE {}
>   returns the graph { :a :b :c}
> 
> 3. ASK {}
>   returns true
> 
> 4. DESCRIBE <uri> WHERE {}
>   Well nobody can tell what it returns :)
>   but it's probably the same as DESCRIBE <uri> for all cases.
> 
> and if WHERE {} is the same as omitting it, then the queries below
> return the same results as the above:
> 
> 1a. SELECT *
> 2a. CONSTRUCT { :a :b :c }
> 3a. ASK
> 4a. DESCRIBE <uri>
>   -- this one's already in the spec
> 
> Dave
> 

	Andy
Received on Thursday, 21 April 2005 20:03:42 GMT

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