Re: Proposal to drop disjunction requirement

On Thu, Sep 30, 2004 at 09:06:24 -0400, Kendall Clark wrote:
> > Disjuntion provides a lot of the same capability as optional matches, but
> > as a developer I've only seen feature reqests expressed in terms of
> > optional match, no disjunction. Many disjunctive queries can be expressed
> > in terms of optionals and value disjunctions, but I have not attempted to
> > show wether all can be or not.
> 
> What would seal the deal for me is a more detailed argument that
> optionals and value disjunctions really do handle all (or nearly all)
> disjunction uses. That is, I want to know which disjunction cases
> *aren't* covered before I support removing it from the language. I
> want to know what I'm giving up, in other words, before I give it up.

Fair enough. I've not yet been able to concoct a disjuntive query that
doesnt have a optional equivalent, but that doesnt mean ther isn't one.

Simple algorithm for conveting a disjuntive expression to one expressed on
optionals: take any common part of each branck of the disjunction, express
that as the must-bind part, place each of the remaining parts of the
disunction as an optional subgraph. You may then need to apply some value
constraints to reduce the set to the answer your interested in. eg:

SELECT ?name
WHERE (<:artifact> <dc:creator> ?name)
   OR ( (<:artifact> <dc:creator> ?c) (?c <rdfs:label> ?name) )

becomes

SELECT ?name
WHERE [ (<:artifact> <dc:creator> ?name) ]
      [ (<:artifact> <dc:creator> ?c) (?c <rdfs:label> ?name) ]

except that ?name = NULL is a valid answer to the optional version, and
I dont think it is to the OR version.

In simpler cases where the path length of the disjunctive components is the
same the differences in the components can be expressed just with value
disjuntion, eg:

SELECT ?source
WHERE (<:artifact> <dc1:source> ?source)
   OR (<:artifact> <dc2:source> ?source)

becomes

SELECT ?source
WHERE (<:artifact> ?p ?source)
AND ?p == <dc1:source> || ?p == <dc2:source>

- Steve

Received on Thursday, 30 September 2004 14:45:26 UTC