Help:Property constraints portal

From Wikidata
Jump to: navigation, search
Gnome-preferences-system.svg
This page is a work in progress, not an article or policy, and may be incomplete and/or unreliable.
Please offer suggestions on the talk page.

русский | বাংলা | català | Deutsch | English | español | suomi | français | magyar | italiano | Lëtzebuergesch | latviešu | македонски | norsk bokmål | Nederlands | polski | português | português do Brasil | română | Scots | shqip | српски / srpski | svenska | 中文(简体)‎ | +/−

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) elected the cat Stubbs (Q7627362) as mayor.

Constraint types[edit]

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).
contemporary
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".
format
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.
inverse
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 manner of death (P1196)  homicide (Q149086).
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.
range
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).
source
This property should only be used for references, not statements or qualifiers. Examples: stated in (P248), imported from (P143).
symmetric
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 occupation (P106)  screenwriter (Q28389).
type
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.

Usage instructions[edit]

There is a user script for displaying constraint violations on item pages. To use it, add the following line to your user/common.js:

mw.loader.load( '//www.wikidata.org/w/index.php?title=User:Jonas_Kress_(WMDE)/check_constraints.js&action=raw&ctype=text/javascript' );
A constraint violation on the Wikidata item for Douglas Adams (Q42). The item has two “native language” statements, “English” and “British English”; the constraint violation message points out that it should only have one (single value constraint).
A constraint violation report displayed by the user script.

You can also check all constraints for an item on Special:ConstraintReport, and see a summary of violations across Wikidata on Wikidata:Database reports/Constraint violations.


Warning: The following sections refer to a future implementation.



Constraint type items[edit]

There is an item for each constraint type, e. g. 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).

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:

< mother (P25) > property constraint (P2302) View with SQID < type constraint (Q21503250) View with Reasonator View with SQID >
relation (P2309) View with SQID < instance of (Q21503252) View with Reasonator View with SQID >
class (P2308) View with SQID < human (Q5) View with Reasonator View with SQID >

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.

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. See also the list of properties using complex constraints.