Questions about OPTIONAL

A few questions about OPTIONAL...

1) If I had a query like this:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?x ?name ?y
WHERE  ( ?x foaf:name  ?name )
       OPTIONAL ( ?x foaf:mbox ?mbox )
       ( ?y foaf:mbox ?mbox )

with data:

@prefix foaf:       <http://xmlns.com/foaf/0.1/> .

_:a  foaf:name       "Alice" .
_:b  foaf:name       "Bob" .
_:b  foaf:mbox       <mailto:bob@work.example> .
_:c  foaf:mbox       <mailto:noname@work.example.org> .


should I get:

x   name    y
=== ======= ===
_:b "Bob"   _:b

or:

x   name    y
=== ======= ===
_:a "Alice" _:b   
_:a "Alice" _:c   
_:b "Bob"   _:b 

In other words, is a variable bound to a value such as NULL by an optional
when there it is not otherwise bound by the block's conditions or does it
truly escape unbound? If it's bound to a NULL, does NULL==NULL?

2) In section 5.3 you say: "If a new variable is mentioned in an optional
block (as mbox and hpage are mentioned in the previous example), that
variable can be mentioned in that block and can not be mentioned in a
subsequent block." 

	a. Does a subsequent _block_ refer to a subsequent _OPTIONAL block_
or does block refer to any logical factor (e.g. the triple after the
optional in my previous example)? If the latter, I think you need to make
that clearer (i.e. define block somewhere).

	b. Does this mean subsequent relative to the order the query was
written or relative to a possible re-ordering by a query processor? Similar
question for section 5.6 - is the shape of the tree determined by the order
as written or the processing order?

3) I'll note that in my opinion this would all be clearer if you spelled out
that A and OPTIONAL B is just shorthand for A and (B or not B) -- or for A
and (B or (not B and v1..n=NULL)). That would lay a firmer foundation for
considering questions such as: "Is OPTIONAL B and A the same as A and
OPTIONAL B?" and generally present the concept in a language people are more
familiar with.

-Geoff

Received on Tuesday, 22 February 2005 19:57:56 UTC