[Mulgara-general] How do I know whether a Mulgara model contains any statements?

Andrae Muys andrae at netymon.com
Mon Mar 31 02:03:49 UTC 2008


On 29/03/2008, at 6:30 AM, Paul Gearon wrote:
> Hi Ramez,
>
>> From the looks of it, your entailed model is indeed empty.  The
> select/count query you are using returns nothing from the WHERE
> clause, and so it never gets to send results to the count, which is
> why there are no results returned instead of 0 (this is a peculiarity
> of subqueries).  A trick here would be to select from the system
> model, and then count on different variables in the count.  The
> resulting query might look like this:
>
> select count(
>       select $x $y $z
>       from <rmi://localhost/server1#nida_1_ent_sameAs>
>       where $x $y $z
>     )
>     from <rmi://localhost/server1#>
>     where $a $b $c;
>
> However, this is just going to give you a 0 instead of the "No results
> returned" that you are getting.

Btw - you will also often see this sort of thing expressed as:

select count(
     select $x $y $z
     from <rmi://localhost/server1/nida_1_ent_sameAs>
     where $x $y $z
   )
   from <rmi://localhost/server#1>
   where $_tmp <mulgara:is> 'ignored'

As Paul said, the reason you weren't getting any results was because  
your outer-query was being performed on an empty model.  Subqueries  
(and counts are a form of subquery) are evaluated with respect to  
each result returned by the outer-query.  Therefore if the outer  
query returns no results at all (as in your original query) the  
subquery is never evaluated.

Note that in the query provided by Paul and myself the outer query  
returns a zero-attribute result with 1 row: this is the #true#[0] or  
'unit' relation, or what Date/Darwin refer to as TABLE_DEE.  This is  
distinct from the zero-attribute result with 0 rows: the #false# or  
'empty' relation, or TABLE_DUM[1].

If you are working with a org.mulgara.query.Answer, the method  
isUnconstrained() tests for the unit relation; the method  
getRowCardinality() returns Cursor.ZERO for the empty relation.

Andrae

[0] iTQL semantics are defined in terms of unification and a  
propositional logic.  #true# and #false# here refer to the result of  
mapping these relations to terms in propositional logic.

[1] For anyone who might be interested, these are respectively the  
multiplicative and additive identities in the abelian semi-ring that  
is the iTQL query algebra we use.

-- 
Andrae Muys
andrae at netymon.com
Senior RDF/SemanticWeb Consultant
Netymon Pty Ltd





More information about the Mulgara-general mailing list