Re: sample query involving disjunction

On Fri, Sep 17, 2004 at 02:42:37AM -0700, Rob Shearer wrote:
> 
> A user wishes to find all the people who are either of type dog owner or own a pet who is  a dog. (In the common case of no inferencing this is a pretty realistic  query.) Some sample data:
> 
> Rob type Person
> Eddie type Person
> Eddie type DogOwner
> Mitch type Person
> Mitch hasPet Fido
> Fido type  Dog
> 
> query
> 
> select $x
> where ($x type  Person)
>       (($x type DogOwner) OR
>        (($x hasPet $y) ($y type Dog))
> 
> Is this query correct?

Looks good to me, an OPTIONAL equivalent would be:

SELECT $x
WHERE ($x type Person)
OPTIONAL ($x type $typeA)
OPTIONAL ($x hasPet $y) ($y type $typeB)
AND $typeA = DogOwner || $typeB == Dog

[OT note] I found using $'s for this query quite distracting.

- Steve

Received on Friday, 17 September 2004 09:57:48 UTC