This query flags all instances of class ?arg1 with property ?arg2 that have values which are not contained in property ?arg4 of instances of class ?arg3. The query tolerates chaotic assignments of language tags.
Legal value check in class instances
CONSTRUCT { _:c0 rdf:type spin:ConstraintViolation . _:c0 spin:violationRoot ?s . _:c0 spin:violationPath ?arg2 .} WHERE { ?s rdf:type ?arg1 . ?s ?arg2 ?value OPTIONAL { ?s2 rdf:type ?arg3 . ?s2 ?arg4 ?value1 FILTER ( str(?value1) = str(?value) ) } FILTER ( ! bound(?value1) ) }
Select class that holds instances with legal values!
Select property that holds legal values!
Select class with instances to be tested!
Instances of class {?arg1} can only contain the same values for property {?arg2} as property {?arg4} in instances of class {?arg3}!
This query flags all instances with property ?arg1 that have characters other than numbers as literal values.
syntax check in all instances: only numbers allowed
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?s . _:b0 spin:violationPath ?arg1 . } WHERE { ?s ?arg1 ?value . FILTER (!regex(str(?value), "^([0-9])*$"^^xsd:string)) }
Syntax rule: only numbers allowed in {?arg1}!
This query flags wrong EAN-13 values in instances of a specified class.
CONSTRUCT { _:c0 rdf:type spin:ConstraintViolation . _:c0 spin:violationRoot ?instance . _:c0 spin:violationPath ?arg2 .} WHERE { ?instance rdf:type ?arg1 . ?instance ?arg2 ?ean LET (?1 := afn:substr(str(?ean), 0, 1)) LET (?2 := afn:substr(str(?ean), 1, 2)) LET (?3 := afn:substr(str(?ean), 2, 3)) LET (?4 := afn:substr(str(?ean), 3, 4)) LET (?5 := afn:substr(str(?ean), 4, 5)) LET (?6 := afn:substr(str(?ean), 5, 6)) LET (?7 := afn:substr(str(?ean), 6, 7)) LET (?8 := afn:substr(str(?ean), 7, 8)) LET (?9 := afn:substr(str(?ean), 8, 9)) LET (?10 := afn:substr(str(?ean), 9, 10)) LET (?11 := afn:substr(str(?ean), 10, 11)) LET (?12 := afn:substr(str(?ean), 11, 12)) LET (?13 := afn:substr(str(?ean), 12, 13)) LET (?value := ( ( ( ( ( ( ( xsd:int(?2) + xsd:int(?4) ) + xsd:int(?6) ) + xsd:int(?8) ) + xsd:int(?10) ) + xsd:int(?12) ) * 3 ) + ( ( ( ( ( xsd:int(?1) + xsd:int(?3) ) + xsd:int(?5) ) + xsd:int(?7) ) + xsd:int(?9) ) + xsd:int(?11) ) )) LET (?check := afn:substr(str(?value), ( fn:string-length(str(?value)) - 1 ), fn:string-length(str(?value)))) FILTER ( ( ( ( xsd:int(?check) + xsd:int(?13) ) != 0 ) && ( ( xsd:int(?check) + xsd:int(?13) ) != 10 ) ) || ( ! regex(str(?ean), "^[0-9]{13}$") ) ) }
Please enter the class holding the instances that shall be tested!
Please enter the property holding the EAN-13!
Incorrect EAN-13 in {?arg2} of {?arg1} class instances!
This query flags all instances with property ?arg1 that have values which are not contained in property ?arg3 of instances of class ?arg2. The query tolerates chaotic assignments of language tags.
Legal value check in all instances
CONSTRUCT { _:c0 rdf:type spin:ConstraintViolation . _:c0 spin:violationRoot ?s . _:c0 spin:violationPath ?arg1 .} WHERE { ?s ?arg1 ?value OPTIONAL { ?s2 rdf:type ?arg2 . ?s2 ?arg3 ?value1 FILTER ( str(?value1) = str(?value) ) } FILTER ( ! bound(?value1) ) }
Property {?arg1} can only contain the same values as property {?arg3} in instances of class {?arg2}!
This query returns all instances that have a value for property ?arg1 above the user defined limit ?arg2. The query tolerates chaotic datatype assignments.
Upper limit check in all instances
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?s . _:b0 spin:violationPath ?arg1 . } WHERE { ?s ?arg1 ?value . FILTER (smf:cast(?value, xsd:decimal) > ?arg2) }
Select property to be tested!
Values in {?arg1} must be lower than {?arg2}!
Subject
Legal value constraints identify values that are either not explicitly allowed or explicitly illegal.
legal value constraints
Creator
This query flags all instances with property ?arg1 that have values which are contained in property ?arg3 of instances of class ?arg2. The query tolerates chaotic assignments of language tags.
Illegal value check in all instances
CONSTRUCT { _:c0 rdf:type spin:ConstraintViolation . _:c0 spin:violationRoot ?s . _:c0 spin:violationPath ?arg1 .} WHERE { ?s ?arg1 ?value OPTIONAL { ?s2 rdf:type ?arg2 . ?s2 ?arg3 ?value1 FILTER ( str(?value1) = str(?value) ) } FILTER bound(?value1) }
Select property holding the illegal values!
Select class with instances holding the illegal values!
Property {?arg1} cannot have the same values as property {?arg3} in class {?arg2}!
This query flags all instances with property ?arg1 that do not have letters as literal values. The query tolerates language tags.
syntax check in all instances: only letters allowed
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?s . _:b0 spin:violationPath ?arg1 . } WHERE { ?s ?arg1 ?value . FILTER (!regex(str(?value), "^([A-Za-z])*$"^^xsd:string)) }
Syntax rule: only letters allowed in {?arg1}!
Syntax constraints identify values that do not adhere to syntactical rules. {@en}
syntax constraints
This query flags all instances of property-and-node element ?arg2 (rdf:parseType="Resource") with property ?arg3 in class ?arg1 that have values which are not contained in property ?arg5 of instances of class ?arg3. The query tolerates chaotic assignments of language tags.
Legal value check in blank node instances of a class
CONSTRUCT { _:c0 rdf:type spin:ConstraintViolation . _:c0 spin:violationRoot ?s . _:c0 spin:violationPath ?arg2 . _:c0 spin:violationPath ?arg3 .} WHERE { ?s rdf:type ?arg1 . ?s ?arg2 ?node . ?node ?arg3 ?value OPTIONAL { ?s2 rdf:type ?arg4 . ?s2 ?arg5 ?value1 FILTER ( str(?value) = str(?value1) ) } FILTER ( ! bound(?value1) ) }
Instances of property-and-node element {?arg2} in class {?arg1} can only contain the same values for property {?arg3} as property {?arg5} in instances of class {?arg4}!
The seventh argument of a function call.
Constraint templates are generalized SPARQL query templates based on the SPARQL Inferencing Framework (SPIN). The query templates represent generic data quality rules that may be used to identify data quality problems, i.e. violations of previously defined constraints.
Value range constraints allow the identification of values that do not obey a certain upper and/or lower limit.
value range constraints
Uniqueness constraints identify values that shall be unique, but are redundant within a certain data set.
uniqueness constraints
This query flags all instances with inconsistant value ranges. Among others it is suitable for value ranges with datatypes xsd:integer, xsd:int, xsd:float, xsd:date, and xsd:dateTime. The literals must be typed.
CONSTRUCT { _:c0 rdf:type spin:ConstraintViolation . _:c0 spin:violationRoot ?instance . _:c0 spin:violationPath ?arg1 . _:c0 spin:violationPath ?arg2 .} WHERE { ?instance ?arg1 ?from . ?instance ?arg2 ?through FILTER ( ?from >= ?through ) }
Please enter the datatype property that shall hold the lower value!
Please enter the datatype property that shall hold the greater value!
Value in {?arg1} cannot be greater than value of {?arg2}!
This query flags all instances with property ?arg1 that have characters other than letters or dots in literal values. The query tolerates language tags.
syntax check in all instances: only letters and dots allowed
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?s . _:b0 spin:violationPath ?arg1 . } WHERE { ?s ?arg1 ?value . FILTER (!regex(str(?value), "^([A-Za-z\\. ])*$"^^xsd:string)) }
Syntax rule: only letters and dots allowed in {?arg1}!
This query returns all instances of class ?arg1 where property ?arg2 is missing. It explicitly tolerates empty literal values in property ?arg2.
Mandatory property check in instances of a class
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?s . _:b0 spin:violationPath ?arg2 . } WHERE { ?s a ?arg1 . NOT EXISTS { ?s ?arg2 ?value . } }
Select class that contains instances to be tested!
Property {?arg2} is mandatory but may contain empty literals for instances of class {?arg1}!
Title
This query returns all instances of class ?arg1 where the literal for ?arg2 is empty. It does not return instances where the whole property ?arg2 is missing.
mandatory literal value check in instances of a class
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?s . _:b0 spin:violationPath ?arg2 . } WHERE { ?s a ?arg1 . ?s ?arg2 ""^^xsd:string . }
Select class to be tested!
Mandatory literals in {?arg2} of class {?arg1}!
This query is designed to test (blank node) instances of the property-and-node element (rdf:parseType="Resource") ?arg2 that are part of the instances of class ?arg 1. The query flags instances of property ?arg2 with properties ?arg3 and ?arg4 that do not have the exact value combination in instances of the trusted reference in class ?arg5. The semantics of property ?arg3 should be equal with property ?arg6, and the semantics of property ?arg4 should be equal with ?arg7. The query tolerates homonymous values, i.e. the same value may be assigned to different dependent values. Value combinations that cannot be found in the trusted reference will also be flagged. The query will also test the existence of a single value in the trusted reference when one property of the tested data is missing.
Functional dependency check in blank node instances of a class with trusted reference
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?s . _:b0 spin:violationPath ?arg3 . _:b0 spin:violationPath ?arg4 . } WHERE { ?s a ?arg1 . OPTIONAL { ?s ?arg2 ?node . OPTIONAL { ?node ?arg3 ?value1 . } OPTIONAL { ?s ?arg4 ?value2 . } } NOT EXISTS { ?s2 a ?arg5 . ?s2 ?arg6 ?value1 . ?s2 ?arg7 ?value2 . } }
Select first property of trusted reference that holds legal values for property 1!
Select property 1 of functional dependency!
Select class that holds instances to be tested!
Select second property of trusted reference that holds legal values for property 2!
Select class of trusted reference that holds instances with legal value combinations!
Select property 2 of functional dependency!
Value combinations of properties {?arg3} and {?arg4} must always be identical with value combinations of properties {?arg6} and {?arg7} of class {?arg5} for all instances of class {?arg1}!
This query returns all instances of class ?arg1 that have a value for property ?arg2 above the user defined limit ?arg3. The query tolerates chaotic datatype assignments.
Upper limit check in all instances of a class
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?s . _:b0 spin:violationPath ?arg2 . } WHERE { ?s a ?arg1 . ?s ?arg2 ?value . FILTER (smf:cast(?value, xsd:decimal) > ?arg3) }
Enter upper limit!
Values in {?arg2} for instances of class {?arg1} must be lower than {?arg3}!
This query flags wrong EAN-13 values.
CONSTRUCT { _:c0 rdf:type spin:ConstraintViolation . _:c0 spin:violationRoot ?instance . _:c0 spin:violationPath ?arg1 .} WHERE { ?instance ?arg1 ?ean LET (?1 := afn:substr(str(?ean), 0, 1)) LET (?2 := afn:substr(str(?ean), 1, 2)) LET (?3 := afn:substr(str(?ean), 2, 3)) LET (?4 := afn:substr(str(?ean), 3, 4)) LET (?5 := afn:substr(str(?ean), 4, 5)) LET (?6 := afn:substr(str(?ean), 5, 6)) LET (?7 := afn:substr(str(?ean), 6, 7)) LET (?8 := afn:substr(str(?ean), 7, 8)) LET (?9 := afn:substr(str(?ean), 8, 9)) LET (?10 := afn:substr(str(?ean), 9, 10)) LET (?11 := afn:substr(str(?ean), 10, 11)) LET (?12 := afn:substr(str(?ean), 11, 12)) LET (?13 := afn:substr(str(?ean), 12, 13)) LET (?value := ( ( ( ( ( ( ( xsd:int(?2) + xsd:int(?4) ) + xsd:int(?6) ) + xsd:int(?8) ) + xsd:int(?10) ) + xsd:int(?12) ) * 3 ) + ( ( ( ( ( xsd:int(?1) + xsd:int(?3) ) + xsd:int(?5) ) + xsd:int(?7) ) + xsd:int(?9) ) + xsd:int(?11) ) )) LET (?check := afn:substr(str(?value), ( fn:string-length(str(?value)) - 1 ), fn:string-length(str(?value)))) FILTER ( ( ( ( xsd:int(?check) + xsd:int(?13) ) != 0 ) && ( ( xsd:int(?check) + xsd:int(?13) ) != 10 ) ) || ( ! regex(str(?ean), "^[0-9]{13}$") ) ) }
This query flags instances with properties ?arg1 and ?arg2 that do not have a corresponding value combination in instances of the trusted reference in class ?arg3. The semantics of property ?arg1 should be equal with property ?arg4, and the semantics of property ?arg2 should be equal with ?arg5. The query tolerates homonymous values, i.e. the same value may be assigned to different dependent values by using different instances in the trusted reference. Value combinations that cannot be found in the trusted reference will also be flagged as incorrect. The query will also test the existence of a single value in the trusted reference when one property of the tested data is missing.
Functional dependency check in all instances with trusted reference
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?s . _:b0 spin:violationPath ?arg1 . _:b0 spin:violationPath ?arg2 . } WHERE { OPTIONAL { ?s ?arg1 ?value1 . OPTIONAL { ?s ?arg2 ?value2 . } } NOT EXISTS { ?s2 a ?arg3 . ?s2 ?arg4 ?value1 . ?s2 ?arg5 ?value2 . } }
Value combinations of properties {?arg1} and {?arg2} must always be identical with value combinations of properties {?arg4} and {?arg5} in class {?arg3} for all instances!
This query returns all instances that have a value for property ?arg1 below the user defined limit ?arg2. The query tolerates chaotic datatype assignments.
Lower limit check in all instances
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?s . _:b0 spin:violationPath ?arg1 . } WHERE { ?s ?arg1 ?value . FILTER (smf:cast(?value, xsd:decimal) < ?arg2) }
Values in {?arg1} must be greater than {?arg2}!
This query flags instances with property ?arg1 and value ?arg2 that do not have value ?arg4 with property ?arg3. It is only suitable for value dependencies with one to one cardinality. The query does not tolerate homonyms and is not restricted to a specific class.
exclusive functional dependency check in all instances
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?s . _:b0 spin:violationPath ?arg3 . } WHERE { ?s ?arg1 ?arg2 . FILTER (!spl:hasValue(?s, ?arg3, ?arg4)) }
Enter functionally dependent value 1 of property 1!
Enter functionally dependent value 2 of property 2!
Value "{?arg2}" of {?arg1} must only have value "{?arg4}" in {?arg3} in all instances!
This query flags all instances of class ?arg1 with property ?arg2 that have values which are contained in property ?arg4 of instances of class ?arg3. The query tolerates chaotic assignments of language tags.
Illegal value check in class instances
CONSTRUCT { _:c0 rdf:type spin:ConstraintViolation . _:c0 spin:violationRoot ?s . _:c0 spin:violationPath ?arg2 . } WHERE { ?s rdf:type ?arg1 . ?s ?arg2 ?value OPTIONAL { ?s2 rdf:type ?arg3 . ?s2 ?arg4 ?value1 FILTER ( str(?value1) = str(?value) ) } FILTER bound(?value1) }
Select class that holds instances with illegal values!
Select property that holds illegal values!
Instances of class {?arg1} cannot have the same values for property {?arg2} as property {?arg4} in class {?arg3}!
This query returns all instances with value ?arg2 for property ?arg1 that do not have an empty literal string for property ?arg3.
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?s . _:b0 spin:violationPath ?arg3 . } WHERE { ?s ?arg1 ?arg2 . FILTER (!spl:hasValue(?s, ?arg3, ""^^xsd:string)) }
Select property that must contain empty literal!
When {?arg1} has value {?arg2}, then {?arg3} has to be empty!
This query returns all instances of class ?arg1 that have a value for property ?arg2 below the user defined limit ?arg3. The query tolerates chaotic datatype assignments.
Lower limit check in all instances of a class
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?s . _:b0 spin:violationPath ?arg2 . } WHERE { ?s a ?arg1 . ?s ?arg2 ?value . FILTER (smf:cast(?value, xsd:decimal) < ?arg3) }
Values in {?arg2} for instances of class {?arg1} must be greater than {?arg3}!
Functional dependencies are dependencies between the values of two or more different properties. Functional dependency constraints check the abidance of functional dependencies.
functional dependency constraints
This RDF document contains a library of data quality constraints represented as SPARQL query templates based on the SPARQL Inferencing Framework (SPIN). The data quality constraint templates are especially useful for the identification of data quality problems during data entry and for periodic quality checks during data usage.
The Data Quality Constraints Library
Christian Fuerber, Martin Hepp, and Markus Wischnewski
Semantic Data Quality Management
This query returns all instances where the value for property ?arg1 is not unique in the tested data set. The query tolerates chaotic language tag assignments.
Uniqueness check for all values in a property
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?a . _:b0 spin:violationPath ?arg1 . } WHERE { ?a ?arg1 ?uniqueValue1 . ?b ?arg1 ?uniqueValue2 . FILTER ((str(?uniqueValue1) = str(?uniqueValue2)) && (?a != ?b)) }
Missing element constraints identify elements in the data set that are missing but required.
missing element constraints
Date
This query flags instances of class ?arg 1 with properties ?arg2 and ?arg3 that do not have the exact value combination in instances of the trusted reference in class ?arg4. The semantics of property ?arg2 should be equal with property ?arg5, and the semantics of property ?arg3 should be equal with ?arg6. The query tolerates homonymous values, i.e. the same value may be assigned to different dependent values. Value combinations that cannot be found in the trusted reference will also be flagged. The query will also test the existence of a single value in the trusted reference when one property of the tested data is missing.
Functional dependency check in class instances with trusted reference
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?s . _:b0 spin:violationPath ?arg2 . _:b0 spin:violationPath ?arg3 . } WHERE { ?s a ?arg1 . OPTIONAL { ?s ?arg2 ?value1 . OPTIONAL { ?s ?arg3 ?value2 . } } NOT EXISTS { ?s2 a ?arg4 . ?s2 ?arg5 ?value1 . ?s2 ?arg6 ?value2 . } }
Value combinations of properties {?arg2} and {?arg3} must always be identical with value combinations of properties {?arg5} and {?arg6} of class {?arg4} for all instances of class {?arg1}!
A legal document giving official permission to do something with the resource.
License
This query returns all instances of class ?arg1 where the literal for ?arg2 is empty or the whole property ?arg2 is missing.
Mandatory literal value and property check in instances of a class
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?this . _:b0 spin:violationPath ?arg2 . } WHERE { { ?this a ?arg1 . ?this ?arg2 "" . } UNION { ?this a ?arg1 . NOT EXISTS { ?this ?arg2 ?value . } } }
Select class that contains intances to be tested!
Property {?arg2} is mandatory and must not contain empty literals for instances of class {?arg1}!
This query flags all instances that do not have a five digit numeric value for property ?arg1.
syntax check in all instances: 5 digit numeric values
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?s . _:b0 spin:violationPath ?arg1 . } WHERE { ?s ?arg1 ?value . FILTER (!regex(str(?value), "^[0-9]{5}$"^^xsd:string)) }
Select the property that contains the US zip codes!
Syntax rule: {?arg1} must contain 5-digit numeric value in all instances!
This query returns all instances of class ?arg1 where the value for property ?arg2 is not unique in the tested data set. The query tolerates chaotic language tag assignments.
Uniqueness check for all values in instances of a class
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?a . _:b0 spin:violationPath ?arg2 . } WHERE { ?a a ?arg1 . ?a ?arg2 ?uniqueValue1 . ?b a ?arg1 . ?b ?arg2 ?uniqueValue2 . FILTER ((str(?uniqueValue1) = str(?uniqueValue2)) && (?a != ?b)) }
This query flags instances of class ?arg1 with property ?arg2 and value ?arg3 that do not have value ?arg5 with property ?arg4. It is only suitable for value dependencies with one to one cardinality. The query does not tolerate homonyms. Not defined dependencies will not be flagged.
exclusive functional dependency check in class instances
CONSTRUCT { _:b0 a spin:ConstraintViolation . _:b0 spin:violationRoot ?this . _:b0 spin:violationPath ?arg4 . } WHERE { ?this a ?arg1 . ?this ?arg2 ?arg3 . FILTER (!spl:hasValue(?this, ?arg4, ?arg5)) }
Value "{?arg3}" of {?arg2} must only have value "{?arg5}" in {?arg4} in instances of class {?arg1}!