Status: | effective |
Progress: | 100% |
Version: | 3.1.0+ |
Help:Constraint schema
A constraint defines a limitation or restriction of a value that can be assigned to a property or class hereby making it possible to shape1 its characteristics and the nature of the "fact" or claim.
The very first value restriction a user comes in contact is the definition of a datatype for a property to describe what a value literal is expected to represent such as a number, a date, a boolean, a page or a simple text.
Additional declarative properties are available to further restrict and describe characteristics of values including:
- special property "Allows value"Lists one permissible value for a property
- special property "Allows pattern"Pattern to match a permissible value
- special property "Has uniqueness constraint"Allows to restrict value annotation to be unique
Yet, adding more of these properties would make maintenance (technical as well as organizational) difficult therefore a different approach has been introduced with Semantic MediaWiki 3.1.0Released on 23 September 2019 and compatible with MW 1.31.0 - 1.33.x..
Constraint schema[edit]
Semantic MediaWiki 3.1.0Released on 23 September 2019 and compatible with MW 1.31.0 - 1.33.x. introduced the "Constraint" class2 together with some schema types (PROPERTY_CONSTRAINT_SCHEMA
schema3 and CLASS_CONSTRAINT_SCHEMA
schema4) to codify and describe constraints using a more formalized and structured approach. Each of the mentioned type supports different properties that can be used to devise an individual schema that can shape a property or members of a class.
The more formalized approach is relying on a structured JSON format to define specific constraint characteristics and include things like:
allowed_namespaces
3 specifies that values need to be a page in one of the allowed namespaces, i.e. values of datatype "Page"Holds names of wiki pages, and displays them as a link only.must_exists
5 specifies that values need to exist before it can be used as annotation element for a property, i.e. values of datatype "Page"Holds names of wiki pages, and displays them as a link only.non_negative_integer
6 specifies that values need to be positive (including 0)shape_constraint
7 specifies that a property is expected to have a certain "shape" such as:max_cardinality
,property
,property_type
ormin_textlength
single_value_constraint
8 specifies that a property expects only a single value per entityunique_value_constraint
9 specifies that values should be unique across the wiki, that the value is likely to be different (distinct) from all other itemscustom_constraint
10 to be used to specify and implement custom constraints
The declarative special property "Constraint schema"Holds the name of a constraint schema which is not restricted to single constraint types11 was introduced to declare and assign one or more schemata to an instance of a property or category to describe constraint requirements of values for a specific instance.
To help users effectively identify and eliminate constraint violations, an indicator12 is placed on top of an article that lists violations for those errors that were classified as constraint errors132.
See also[edit]
- For users and admins
- Glossary page on constraints
- Help page on schema types
- List of schema types
- Help page on special property "Constraint schema"Holds the name of a constraint schema which is not restricted to single constraint types
- Help page on constraint errors
- For developers
- The following document describes the technical details on how to extend the constraint checks in SMW core.
- How to register a custom constraint
References
- ^ https://www.w3.org/TR/shacl/
- a b Semantic MediaWiki: GitHub pull request gh:smw:3830
- a b Semantic MediaWiki: GitHub pull request gh:smw:3746
- ^ Semantic MediaWiki: GitHub pull request gh:smw:4033
- ^ Semantic MediaWiki: GitHub pull request gh:smw:3981
- ^ Semantic MediaWiki: GitHub pull request gh:smw:3970
- ^ Semantic MediaWiki: GitHub pull request gh:smw:4069
- ^ Semantic MediaWiki: GitHub pull request gh:smw:4010
- ^ Semantic MediaWiki: GitHub pull request gh:smw:3908
- ^ Semantic MediaWiki: GitHub pull request gh:smw:3966
- ^ Semantic MediaWiki: GitHub pull request gh:smw:3829
- ^ Semantic MediaWiki: GitHub pull request gh:smw:3968
- ^ Semantic MediaWiki: GitHub pull request gh:smw:3792