Help:Property constraints portal

Wikidata property constraint violation report on item page.

Property constraints are rules on properties that specify how properties should be used. The Wikidata model itself is very flexible: nothing stops you from adding Universe (Q1) as head of government (P6). However, a constraint on the property can tell you that a head of government (P6) is usually a human.

Constraints are hints, not firm restrictions, and are meant as a help or guidance to the editor. They can have exceptions: for example, the town of Talkeetna (Q668224) had the cat Stubbs (Q7627362) as honorary mayor.

Some constraint types, currently one-of constraint and allowed qualifiers constraint, are also used to provide better suggestions when editing statements.

Note: Technically a property constraint is a statement (on a property) of a particular constraint type, specified via property constraint (P2302). So strictly speaking constraint and constraint type refer to two different things, for the sake of brevity this page however sometimes refers to constraint types simply as constraints.

edit
Item Help page Violation message
single-value constraint (Q19474404) Help:Property constraints portal/Single value MediaWiki:Wbqc-violation-message-single-value
distinct-values constraint (Q21502410) Help:Property constraints portal/Unique value
format constraint (Q21502404) Help:Property constraints portal/Format
subject type constraint (Q21503250) Help:Property constraints portal/Type
value-type constraint (Q21510865) Help:Property constraints portal/Value type
multi-value constraint (Q21510857) Help:Property constraints portal/Multi value MediaWiki:wbqc-violation-message-multi-value

Datatype-independent constraints

edit

Constraints to restrict where a property may be added

edit
property scope constraint
This property should only be used for certain scopes (main value of a statement, in a reference, as qualifier).
allowed-entity-types constraint
This property should only be used on certain entity types. Example: Wikidata property example (P1855) (properties).
subject type constraint
Items with this property should have a certain type. Example: Items with date of birth (P569) should be instance of (P31) human (Q5) or animal (Q729).
conflicts-with constraint
Items with this property should not have certain other properties or statements. Examples: sex or gender (P21) conflicts with author (P50), which in turn conflicts with instance of (P31)human (Q5).
item-requires-statement constraint
Items using this property should also have certain other statements. For example, items with killed by (P157) should have place of death (P20), date of death (P570) and manner of death (P1196)homicide (Q149086).
contemporary constraint
Items with this property and values for this property should coexist at some point in time. Examples: mother (P25), country of citizenship (P27).
label in language constraint
Items using this property should also have a label in a certain language. For example, items with Vietnamese middle name (P8500) should have a Vietnamese label.
description in language constraint
Items using this property should also have a description in a certain language.
lexeme requires language constraint
This property should be used on lexemes in a certain language. For example, Gran Enciclopèdia Catalana ID (former scheme) (P1296) should be used on Catalan (Q7026) lexemes.
lexeme requires lexical category constraint
lexeme-value-requires-lexical-category constraint


Constraints regarding the number of values

edit
single-value constraint
Items should have no more than one statement with this property. Often used for identifiers, but also many other properties: for example, people generally only have a single place of birth (P19) and place of death (P20).
single-best-value constraint
Items should have one “best” statement with this property. Often used for properties that can change over time: for example, cities and countries usually have a single current head of government (P6).
multi-value constraint
Items should have more than one statement with this property (or none). Rarely used, but examples include cast member (P161), has tense (P3103) and has grammatical mood (P3161).
distinct-values constraint
aka. unique value and distinct value. No two items should share a value for this property; each item’s value should be unique across all statements for this property in all of Wikidata. Almost all identifier properties have this constraint, since an identifier (ISBN, freebase ID, …) should uniquely identify an entity. Other examples include flag (P163) and anthem (P85).

Constraints regarding qualifiers

edit
allowed qualifiers constraint
Statements for this property should not have any qualifiers other than the listed ones. Examples: continent (P30) with qualifiers start time (P580) and end time (P582), and Freebase ID (P646) with no qualifiers at all.
required qualifier constraint
Statements for this property must have all of the listed qualifiers. Example: stock exchange (P414) with ticker symbol (P249) and start time (P580).

Constraints regarding references

edit
citation-needed constraint
Statements for this property should have at least one reference. Example: properties likely to be challenged.

Datatype-specific constraints

edit

Constraints for datatype item/entity

edit
value-type constraint
Values for this property should have a certain type. Example: mother (P25) should be instance of (P31) human (Q5) or animal (Q729).
one-of constraint
Values for this property should be one of a given set of items. Example: driving side (P1622) should be either left (Q13196750) or right (Q14565199).
none-of constraint
Values for this property should not be one of a given set of items. Example: instance of (P31) should not be woman (Q467).
value-requires-statement constraint
aka. _target required statement. Values for this property should also have certain other statements. For example, screenwriter (P58) values should have sex or gender (P21) and occupation (P106)screenwriter (Q28389).
symmetric constraint
Statements using this property should always exist in both directions. Examples: sibling (P3373), twinned administrative body (P190).
inverse constraint
Statements using this property should always have an inverse statement. Examples: father (P22)/mother (P25) with child (P40).
complex constraint value label
Values for this property have to have a label in a specific language that matches a specific format.

Constraints for Quantity

edit
integer constraint
Values for this property should be integers without decimal places.
allowed units constraint
Values for this statement should only use certain units (or none). Examples: term length of office (P2097) (unit: year (Q577)), population (P1082) (no units).
no-bounds constraint
Values for this property should not use upper and lower bounds. This applies to most non-physical properties with quantity data type, for which the concept of uncertainties is not defined.
range constraint
Values for this property should be within a certain range or interval. Examples: flattening (P1102) is always between 0 and 1, and UTC date of spacecraft launch (P619) should not be before .
difference-within-range constraint
aka. difference within range. The difference between values for this property and for another property should be within a certain range or interval. For example, the difference between date of birth (P569) and date of death (P570) should be between 0 and 150 years.

Constraints for Time

edit
range constraint
Values for this property should be within a certain range or interval. Examples: flattening (P1102) is always between 0 and 1, and UTC date of spacecraft launch (P619) should not be before .
difference-within-range constraint
aka. difference within range. The difference between values for this property and for another property should be within a certain range or interval. For example, the difference between date of birth (P569) and date of death (P570) should be between 0 and 150 years.

Constraints for string-based datatypes

edit

The constraint types listed in this section can be used for properties that have a string-based datatype.

format constraint
Values for this property should have a certain format. Often used for identifiers (n digits long, starts with a certain letter, consists of digits, …).
edit
Commons link constraint
Values for this statement should be valid links to Wikimedia Commons. Examples: image (P18) (“File” namespace), Commons category (P373) (“Category” namespace).

Constraints alphabetically

edit

Several constraints have their own predefined templates and are listed at Help:Property constraints/list of constraints.

Usage instructions

edit

Constraint reports are shown for all logged in users when they visit an entity page.

 
A constraint violation report displayed on an item page.

You can also check all constraints for an item on Special:ConstraintReport. This page is provided by WikibaseQualityConstraints (also known as "constraints extension"). A bot also maintains reports of constraint violation; see a summary of violations across Wikidata on Wikidata:Database reports/Constraint violations.

Constraint type items

edit

There is an item for each constraint type, e.g. subject type constraint (Q21503250).

Constraint statements on properties

edit

Constraints for a property are specified as statements on the property, using property constraint (P2302) and the constraint type item. For example: sibling (P3373)property constraint (P2302)symmetric constraint (Q21510862). Deprecated statements are ignored, so changing a constraint statement’s rank to “deprecated” is a convenient way to temporarily disable a constraint without completely removing it.

Constraint parameters

edit

Many constraints are configurable: one of has a list of the permitted values, type contains the type, etc. These settings which configure the constraint are called parameters.

Constraint parameters are specified as qualifiers on the statement. For example:

There are several general parameters that can be added to any constraint statement:

constraint status (P2316)
With the value mandatory constraint (Q21502408), this parameter can be used to mark a constraint as mandatory. Violations of mandatory constraints are more severe than violations of non-mandatory ones. Non-mandatory constraints should have a value of suggestion constraint (Q62026391).
exception to constraint (P2303)
Lists known exceptions to the constraint. On the items listed under this parameter, the constraint is not checked.
group by (P2304)
Contains a property by the values of which constraint violations should be grouped. That is, when the database reports list violations for a constraint (for all items), the items with violations are grouped by the value they have for the property given in the group by (P2304) parameter. (The constraints extension does not use this parameter.)
constraint scope (P4680)
Specifies in which part of a statement the constraints applies, using the three special values constraint checked on main value (Q46466787), constraint checked on qualifiers (Q46466783) and constraint checked on references (Q46466805). Use any combination of these values to specify where a constraint should be checked. If the parameter is not specified, the default scope depends on the constraint type. (Note that the database reports only list violations on the main value of a statement.)
constraint clarification (P6607)
Provides a simple explanation for the purpose of the constraint (why it exists) and recommended actions to resolve the constraint.


When constraints aren’t checked

edit

Each individual constraint can list exceptions in its constraint parameters (see above); on any statements of that item, that constraint will not be checked at all. (There is currently no mechanism for specifying other entity types as exceptions, or for listing exceptions in a different way.)

On properties like Wikidata property example (P1855), Wikidata property example for properties (P2271), etc., as defined in wgWBQualityConstraintsPropertiesWithViolatingQualifiers, all constraint checks on qualifiers are skipped. For these properties, qualifiers have a different meaning than usual: they’re more similar to main statements than qualifiers of that statement, so it doesn’t really make sense to check constraints on those qualifiers.

WikibaseQualityConstraints only uses normal-rank and preferred-rank constraint statements and ignores deprecated-rank ones, so setting a constraint’s rank to deprecated can be used to “hide” it from WikibaseQualityConstraints. (KrBot uses all constraint statements regardless of rank.)

Custom constraints

edit

With some knowledge of SPARQL one can make very complex constraints for certain properties, above and beyond the restrictions mentioned above. More information is available at Template:Complex constraint. The reports are maintained by a third-party bot and not part of Wikibase software. See also the list of properties using complex constraints.

See also

edit
  NODES
Done 1
see 6
Users 1