Re: Another alternative to OR

On Mon, Oct 11, 2004 at 09:44:50AM +0100, Andy Seaborne wrote:
> Suppose this is a library with its own accession system and the query is
> doing the simple thing of accession number to title and author
> 
> SELECT ?title ?author
> WHERE   (?x lib:accession ?n)
>         (?n lib:number "123.456.789")
>         { (?x dc10:title ?title) OR (?x dc11:title ?title) }
>         { (?x dc10:creator ?author) OR (?x dc11:creator ?author) }

Surely you would expand this as:

SELECT ?title ?author
WHERE   (?x lib:accession ?n)
        (?n lib:number "123.456.789")
        (?x ?title ?title)
        (?x ?creator ?author)
AND ?title == dc10:title || ?title == dc11:title
    ?creator == dc10:creator || ?creator == dc11:creator

The point I was making is that union queries offer an additional way of
expressing disjunctive expressions without going into territory that is
unexplored by SQL engines and optimisers.

I dont buy the argument that its better to let application writers express
the queries in whatever way takes thier fancy (ie. too much rope) and then
optimise it later. I can see a future where I spend a lot of my time
explaining to users how to rewrite thier queries to make them perform
better.

- Steve

Received on Monday, 11 October 2004 09:02:41 UTC