Help:Property declaration

This help page informs about how to declare properties. Semantic MediaWiki has several built-in datatypes from which we can choose for properties. For our previous population example, the appropriate datatype is Number. We want to assign to property "Has population" a special property that specifies it has the datatype "number". To support this, Semantic MediaWiki has a built-in special property called Has type. We use the same syntax for this special property as for any other property, so on the Property:Population page, we write the following which specifies the datatype of the property:

Has type::number

Semantic MediaWiki knows a number of special properties like Has type. Regardless of whether these properties have their own articles in the wiki, they have a special built-in meaning and are not evaluated like other properties.

Datatypes are very important for evaluating properties. Firstly, the data type determines how tools should handle the given values, e.g. for displaying values and sorting values in search results. Secondly, the data type is required to understand which values have the same meaning, e.g. the values "1532", "1,532", and "1.532e3" all encode the same number. Finally, some data types have special behavior, as will be described below. For these reasons, every property used should be defined with a data type.

The reason we didn't have to specify a data type for the "Is capital of" property above is that the default data type is Page, which displays as a link. Even though the datatype Page is the default, you should explicitly specify a datatype for every property, just to prevent confusion or later redefinition with an unintended type. It is also possible for the administrator of an website using Semantic MediaWiki to change the default datatype.

The same mark-up for properties that are links to pages also works for properties of other datatypes. Here are some more examples:

One cannot include a full stop "." like in  in a property name since this conflicts with the syntax for creating property chains.

Special properties
We mentioned the special property Property:Has type that you use to define the data type of a property. Semantic MediaWiki has other predefined special properties that have special meaning (even if you do not create property pages for them in your wiki). You cannot use these names for your own properties, but since Semantic MediaWiki 1.4.0 you can use them in browsing and querying interfaces just like all other properties. For more information, see special properties help and the individual property pages.