Help:Inverse properties

From semantic-mediawiki.org
Jump to: navigation, search
SMW user manual
Introduction
Editing
Properties and types
Special properties
Inverse properties
Custom units

Semantic templates

Service links

Browsing interfaces
Special:Ask
Special:Browse
Semantic search
Selecting pages
Strict comparators
Displaying information
Result formats
Inline queries
Querying for queries
Concepts
Inferencing
Semantic Web
RDF export

External tools

Importing vocabulary

SMW admin manual

Since SMW 1.5.0, it is possible to invert the direction of a property with datatype Page in semantic search (inline queries, concepts) and on browsing interfaces (Special:Ask, Special:Browse).

In order to achieve this, simply write "-" in front of property name anywhere in SMW to refer to the inverse direction of a property. Thus the property relates to the same pages but with annotated page and property value exchanged. For example, the inverse of "parent of" is "-parent of". This intuitively means "child of". Because of this a property with that name does not have to be created and annotated explicitly. However, note that "-father of" corresponds to "has male parent", not to "son of"!

SMW does not support naming of inverses nor is it possible to assign a value to an inverse property (e.g. [[-Parent of::Michael]] will not work). SMW allows inverses to be used for retrieving data. This works in browsing interfaces, queries, and query output directives. In queries it works only for properties of datatype Page.

Simple Example

To convert inverse property syntax to English, you can read [[-Has mother::Michael]] as get value of "has mother" from page "Michael".

For example, let's say the page "Michael" has the following wikitext:

Michael's mother is [[Has mother::Carol]].

Then on another page you could do:

{{#ask: [[-Has mother::Michael]] }}

Since get value of "has mother" from page "Michael" equates to "Carol", the output of this #ask query would be just:

Carol

Remember that the value of "has mother" must be a page. Inverse properties do not work on properties of type number, date, etc. And it only works within #ask and #show queries.

See also


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

Help:Inverse properties en 1.5.0