Another alternative to OR

Another systatic alternative to the inline disjunctive exressions I
dislike so much :) is UNION queries, which have been discussed a little,
as "multiple queries per request", "multiple WHEREs" or something similar.

So

	SELECT ?name
	WHERE { (?x foo:name ?name) }
	      OR { (?x bar:hasName ?name) } 

could be writen as:

	SELECT ?name
	WHERE (?x foo:name ?name)
	UNION
	WHERE (?x bar:hasName ?name)

or some other equivalent (you wany want to repeat the SELECT).

This has the advantage over OR that it doesnt explode the query
complexity, and doesnt have such complicated interactions with OPTIONAL,
as every allowed combination of disjunctive expressions has to be spellt
out. The query evaluator can simply execute each match in turn, or it may
optimise it if it wishes to get more performance.

The downside is that it will make the queries more verbose if you have a
complicated disjunctive expression.

- Steve

Received on Tuesday, 5 October 2004 13:21:16 UTC