Simple cardinality tests with SPARQL

  Hello,
to check for property cardinalities within an RDF document I used following queries:

  - for cardinality 0-1: NOT(Q2)
  - for cardinality 1: Q1 AND NOT(Q2)
  - for cardinality 1-n : Q1


# Q1
ASK
WHERE
{
     ?s rdf:type pfx:Foo; pfx:bar ?b .
}

# Q2 - no solutions, no duplicates
ASK
WHERE
{
     ?s rdf:type pfx:Foo;
     pfx:bar ?b;
     pfx:bar ?b1
     FILTER(?b != ?b1)
}

Could these queries be formulated in a simpler, more elegant way ?

   Many thanks for your suggestions
     Jaro



-- 
Jaroslav Pullmann
Web Compliance Center - Fraunhofer FIT
Schloss Birlinghoven, D-53757 Sankt Augustin, Germany
Phone: +49-2241-142623    Fax: +49-2241-142065

Received on Wednesday, 12 November 2008 14:32:38 UTC