Problems with WITH and FROM

The WITH and FROM constructs embody some unfortunate choices.

Background graphs represent the most common case, while named
graphs are going to see less use.  The FROM keyword in SQL will
seem most familiar to programmers, and its natural that it would
refer to background graphs.  The current language spec reverses this
commonsense idea, teaming the less used keyword WITH with the
more used type of graphs.

Suppose an unsuspecting programmer writes the following

SELECT ?a
FROM my:g
WHERE (?a my:foo my:b)

The FROM clause will either be ignored or an error message might
be thrown, but its not going to give the "expected" results.  Substituting
WITH for FROM fixes the problem, but it would be much better
if we didn't design a propensity for human error right into the language.

The FROM clause inherently defines a disjunction (the poorly-
named UNION construct).  However, by masking the fact that
it defines a disjunction, it also masks a lack of generality.  Consider
the following query, which either is legal or should be (modulo my
ignorance of SPARQL syntax):

SELECT ...
WHERE
   Graph ?g1 {...}
   Graph ?g2 {...}
   AND
     {{?g1 = my:a} UNION {?g1 = my:b}
   AND
    {{?g2 = my:c} UNION {?g2 = my:d}}

This query is not expressible using the FROM clause.  This example shows
that the FROM clause is superfluous (or should be), and non-general.

Best would be to eliminate it entirely, and rename "WITH' to 'FROM'.

If you really want convenience, which is what FROM seems to be all
about, try adding an 'IN' operator, e.g.,  something like

     ?g1 IN {my:a, my:b}
AND
     ?g2 IN {my:c, my:dJ}

Cheers, Bob

Received on Sunday, 20 February 2005 23:00:35 UTC