Help:Property constraints portal
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) elected the cat Stubbs (Q7627362) as mayor.
The following types of constraints are available:
- allowed qualifiers
- See "qualifiers".
- allowed units
- See units.
- commons link
- Values for this statement should be valid links to Wikimedia Commons. Examples: image (P18) (“File” namespace), Commons category (P373) (“Category” namespace).
- Items with this property and values for this property should coexist at some point in time. Examples: mother (P25), country of citizenship (P27).
- diff within range / 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.
- distinct values
- See "unique value".
- Values for this property should have a certain format. Often used for identifiers (n digits long, starts with a certain letter, consists of digits, …). Described using a form of regular expression.
- Statements using this property should always have an inverse statement. Examples: father (P22)/mother (P25) with child (P40).
- item / item requires claim
- 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 .
- mandatory qualifiers
- Statements for this property must have all of the listed qualifiers. Example: stock exchange (P414) with ticker symbol (P249) and start time (P580).
- multi value
- 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).
- one of
- Values for this property should be one of a given set of items. Example: manner of death (P1196) should be one of natural causes (Q3739104), accident (Q171558), suicide (Q10737), homicide (Q149086), pending investigation (Q15729048), capital punishment (Q8454).
- qualifier / used as qualifier
- This property should only be used for qualifiers, not statements or references. Examples: street number (P670) (qualifier of located on street (P669)).
- qualifiers / allowed qualifiers
- 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.
- Values for this property should be within a certain range or interval. Examples: flattening (P1102) is always between 0 and 1, and time of spacecraft launch (P619) should not be before .
- single value
- 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).
- This property should only be used for references, not statements or qualifiers. Examples: stated in (P248), imported from (P143).
- Statements using this property should always exist in both directions. Examples: sibling (P3373), sister city (P190).
- target required claim / value requires claim
- Values for this property should also have certain other statements. For example, screenwriter (P58) values should have sex or gender (P21) and .
- 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).
- unique value / distinct values
- 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).
- units / allowed units
- Values for this statement should only use certain units (or none). Examples: term length of office (P2097) (unit: year (Q577)), population (P1082) (no units).
- used as qualifier
- see qualifier.
- used as reference
- see source.
- used for values-only
- see value only.
- value only / used for values-only
- This property should only be used for statements, not qualifiers or references. Examples: most properties.
- value requires claim
- See "target required claim"
- value type
- Values for this property should have a certain type. Example: mother (P25) should be instance of (P31) human (Q5) or animal (Q729).
Several constraints have their own predefined templates and are listed at Help:List of property constraints.
There is a user script for displaying constraint violations on item pages. To use it, add the following line to your user/common.js:
|Warning: The following sections refer to a future implementation.|
Constraint type items
There is an item for each constraint type, e. g. type constraint (Q21503250).
Constraint statements on properties
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 two 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.
- exception to constraint (P2303)
- Lists known exceptions to the constraint. On the items listed under this parameter, the constraint is not checked.
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. See also the list of properties using complex constraints.