Re: Added Requirement: Static Constraints

On 1/16/2015 1:45, Karen Coyle wrote:
> Thanks, Holger. As usual, I need to do this "by example" because it's 
> quite likely that my vocabulary differs from that of others here.
>
> Use cases: I have data that uses dct:title in various places, and I 
> want to say that wherever it is used it can only be used once for each 
> subject in my data. Here's some data:

The following static constraint could express that scenario:

ex:AtMostOneTitleConstraint
     a :StaticConstraint ;
     :message "For a given subject, dct:title can only be used once." ;
     :predicate dct:title ;
     :sparql """
             # Find all subjects that have two distinct values of dct:title
             SELECT (?subject AS ?root)
             WHERE {
                 ?subject dct:title ?title1 .
                 ?subject dct:title ?title2 .
                 FILTER (?title1 != ?title2) .
             }
         """ ;
.

>
> 1)
> subjectA dce:creator "Somebody" .
> subjectA dct:title "Some title" .
> subjectA bf:subject http://.... .
> subjectB dce:creator "Someone else" .
> subjectB dct:title "Another title" .
>
> 2)
> subjectA dce:creator "Somebody" .
> subjectA dct:title "Some title" .
> subjectA bf:subject ex:subject1 .
> subjectB dce:creator "Someone else" .
> subjectB dct:title "Another title" .
> subject1 dct:title "A related book" .
>
> That's a pretty stupid example, and the data is more sophisticated 
> than that, of course. My questions are:
>
> a) because this data does not use rdf:type (unless inferred, and let's 
> say it isn't), does subject "s" constitute a node/graph/shape?

In the absence of an rdf:type triple, we indeed need to declare this as 
a static constraint that is not attached to any class but executed for 
the whole graph.

> b) substitute "skos:prefLabel" here and a rule that skos:prefLabel can 
> occur only once per each "X" (X because I dont know what to call it) - 
> is that the same case?

I think that's similar, only that we could probably associate that 
constraint with skos:Concept, because that is where skos:prefLabel is 
supposed to be used. However, skos:prefLabel should have another 
constraint that it should only have one value per language tag, which is 
a variation of the query above. Here is the corresponding SPIN query

CONSTRUCT {
     _:b0 a spin:ConstraintViolation .
     _:b0 rdfs:label ?message .
     _:b0 spin:violationRoot ?this .
     _:b0 spin:violationPath skos:prefLabel .
}
WHERE {
     ?this skos:prefLabel ?label1 .
     ?this skos:prefLabel ?label2 .
     FILTER ((lang(?label1) = lang(?label2)) && (?label1 != ?label2)) .
     BIND (CONCAT("Constraint S14: a resource has no more than one value 
of skos:prefLabel per language tag (@", lang(?label1), ").") AS ?message) .
}

> c) is this really a new use case, or a variation on existing ones?

I believe the Requirements cover this scenario. Whether you want to 
write it up as a new User Story is up to you.

HTH
Holger

Received on Thursday, 15 January 2015 22:48:42 UTC