Help:Many-valued properties

From HackerspaceWiki
Jump to: navigation, search

A many-valued property maps between a subject and two or more values. This is distinct from the most common type of property, a binary property which maps between a single subject and a single value. A many-valued property cannot be split up into separate properties, because the set of values that it groups are all interconnected in some way.

Implementation in SMW 1.0[edit]

In Semantic MediaWiki 1.0, you can specify that a property takes multiple values by listing more than one type in its Property:Has type, separated by ; (semicolons).

For example, on ontoworld.org, Property:Employment includes an employer, job title, start date and end date; it is specified as [[has type::Page; String; Date; Date]]. In articles you can add this property, specifying any subset of those four values, again separated by ; (semicolons). You can use "" (two double quotation marks) or ? for omitted values.

The first value appears normally, while the remaining ones appear within parentheses, separated by commas.

Semantic search[edit]

You can search on many-valued properties similarly to other properties; see Help:Semantic search. As with any property, you can use the + wildcard to select all pages with some value for a many-valued property, for example {{#ask: [[Employment::+]] }} To find pages that match a particular value for any of the parts of a many-valued property, just list the values to match, separated by semicolons. If you don't care about the value of one of the datatypes, use ? to match any value for it including omitted. You can also use comparators (such as ! for not, < for less than or equal to, etc.) for each of the datatype's values.

For example,

 {{#ask: [[Employment:: ?; !professorship; <1950-12-31; ?]] }}

selects values for the property Employment with any value for the employer string, where the title string is not "professorship", the start date is before 1951, and with any value for end date.

Limitations[edit]

  • You cannot use the special Allows value property to limit the values of any element of a many-valued property.
  • You cannot use the special Display units property to control how a specific element appears.
  • You cannot set the layout of the values; they will always appear as a comma-separated list.
  • You cannot create a timeline query of many-valued properties.

Related links[edit]

This documentation page applies to all SMW versions from 1.0 to the most current version.
      Other languages: nl