Defining cardinality of properties: Tracker SPARQL Library Reference Manual

## Defining cardinality of properties

By default, properties are multivalued, there are no restrictions in the number of values a property can store.

    INSERT DATA { <cat> a ex:Mammal .
                  <dog> a ex:Mammal .

                  <peter> a ex:Mammal ;
                        ex:pets <cat>, <dog> }

Wherever this is not desirable, cardinality can be limited on properties through nrl:maxCardinality.

    ex:cromosomes a rdf:Property;
                  rdfs:domain ex:Eukaryote;
                  rdfs:range xsd:integer;
                  nrl:maxCardinality 1.

This will raise an error if the SPARQL updates in the endpoint end up in the property inserted multiple times.

    # This will fail
    INSERT DATA { <cat> a ex:Mammal;
                        ex:cromosomes 38;
                        ex:cromosomes 42 }

    # This will succeed
    INSERT DATA { <donald> a ex:Mammal;
                           ex:cromosomes 47 }

Tracker does not implement support for other maximum cardinalities than 1.