Ninus; Both of these queries can be accomplished with Aggregates,
which are included in the SPARQL 1.1 working draft and have been
supported by Composer for a while.

There are probably a few ways to do the first one.  I'll use
aggregates along with turning rdfs:subClassOf into a transitive
relationship ('+' and '*" syntax).

SELECT count(?inst)
WHERE {
    ?cls rdfs:subClassOf+ owl:Thing .
    ?inst a ?cls .
}

If you need to bind the count to a variable, then use SELECT (count(?
inst) AS ?x).

The second can be performed with a simple aggregate.  Note that SPARQL
is RDF-based.  It does not entail any OWL or RDFS semantics, so you
can match the triple pattern directly.

SELECT count(*)
WHERE {
    ?x :Prop ?z .
}

-- Scott

On Oct 30, 4:35 pm, Nick Khamis <[email protected]> wrote:
> Hello everyone. I am looking for a couple of Sparql Queries... Assume the
> following:
>
> Concept: A, B
> Property: p
> Individuals: x, y, z
>
> A(x)
> A(y)
> B(z)
> p(A,B)
> p(x,z)
>
> Basically what I am looking for are the following:
>
> * When opening up an ontology using TBC we get a number of individuals that
> are of type something that is a subclass of owl:thing. What would a sparql
> query look like that would return the number of individuals that are of type
> owl:Thing that of course has subclasses that the individuals are direct
> types of.
>
> * A query that returns the number of created relationships "not number of
> object and datatype properties". I am talking about "p(x,z)". Since the
> domain for p is A which x and y are individuals of, but a relationship is
> created only for x using the property p then the query should return 1 for
> the p(x,y) relationship.
>
> Thanks in Advanced,
> Ninus.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TopBraid Composer Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/topbraid-composer-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to