Help:属性约束门户

This page is a translated version of the page Help:Property constraints portal and the translation is 54% complete.
Outdated translations are marked like this.
项页面上的维基数据属性约束违例报告。

属性约束是属性上的规则,它指定属性应如何使用。维基数据模型本身很灵活:没有什么阻止您添加Universe (Q1)head of government (P6)。然而,属性上的约束会告知您head of government (P6)通常是人类。

约束是提示,而不是严格限制,意在帮助或指导编辑者。它们可以有例外:例如Talkeetna (Q668224)将叫做Stubbs (Q7627362)的猫选举为市长。

一些约束类型,目前包括one-of constraintallowed qualifiers constraint,也用于在编辑陈述时提供更好的建议

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.

常见约束类型

Item 帮助页面 违例消息
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

Constraints to restrict where a property may be added

property scope constraint
这个属性只能用在特定范围内(一个陈述的主要值、在参考资料中、作为修饰项)。
allowed-entity-types constraint
这个属性只能用于特定的实体类型。例如:Wikidata property example (P1855)(属性)。
subject type constraint
具有這個屬性的項應當具有特定類型。例如:具有date of birth (P569)的項應當instance of (P31) human (Q5)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
使用这个属性的项应当还有某种特定语言的标签。例如,有Vietnamese middle name (P8500)的项应当有越南语标签。
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

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

allowed qualifiers constraint
这个属性的陈述不能有任何修饰项,已经列出的除外。例如:continent (P30)有修饰项start time (P580)end time (P582),而Freebase ID (P646)则没有任何修饰项。
required qualifier constraint
这个属性的陈述必须含有全部列出的修饰项。例如:stock exchange (P414)ticker symbol (P249)start time (P580)

Constraints regarding references

citation-needed constraint
這個屬性的聲明應當至少有一個參考文獻。例如:可能受到挑戰的屬性

Datatype-specific constraints

Constraints for datatype item/entity

value-type constraint
這個屬性的值應當具有特定類型。例如:mother (P25)應當instance of (P31) human (Q5)animal (Q729)
one-of constraint
這個屬性的值應當是給定項目集合中的一個。例如:driving side (P1622)應當是left (Q13196750)right (Q14565199)
none-of constraint
這個屬性的值不應該是一個給定項目集合中的任何一個。例如:instance of (P31)不應當是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
使用這個屬性的聲明應當總是雙向存在。例如:sibling (P3373)depicts (P180)
inverse constraint
使用这个属性的陈述应当总是存在逆陈述。例如:father (P22)/mother (P25)child (P40)
complex constraint value label
Values for this property have to have a label in a specific language that matches a specific format.

Quantity 的约束

integer constraint
这个属性的值应当是整数,没有小数位。
allowed units constraint
这个属性的值只能使用特定单位(或没有)。例如:term length of office (P2097)(单位:year (Q577)),population (P1082)(无单位)。
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
这个属性的值应当处于某个范围或区间内。例如:flattening (P1102)总在0和1之间,UTC date of spacecraft launch (P619)不能在之前。
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.

Time 的约束

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

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

format constraint
这个属性的值应当有特定格式。常用于标识符(长度n位,以特定字母开始,包含数字……)。

Constraints for Commons links

Commons link constraint
这个属性的值应当是指向Wikimedia Commons的有效链接。例如:image (P18)(“文件”命名空间),Commons category (P373)(“分类”命名空间)。

约束(按首字母)

部分约束有自己的预定义模板,完整列表见Help:Property constraints/list of constraints

使用说明

当任何登录用户浏览一个项的页面时就会显示约束报告。

 
在一个项的页面中展示的违反约束报告。

你也可以在Special:ConstraintReport中檢查一個項的所有約束,和在維基數據:數據庫報告/約束違例中查看維基數據的約束違例匯總。

约束类型项

每个约束类型都有对应的项,例如 subject type constraint (Q21503250)

属性上的约束声明

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.

约束参数

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 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):列出约束的已知例外。这个参数下的项目约束不被检查。
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.


何时不检查约束

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.)

自定义约束

如果有一些SPARQL知识,人们还能对一些属性创建非常复杂的约束,这些约束没有上述那些限制。Template:Complex constraint有更多信息。另外参见使用复杂约束的属性的列表。

参见