Difference between revisions of "Help:SMW"

From DUNE
Jump to navigation Jump to search
 
Line 12: Line 12:
 
== Creating a class ==
 
== Creating a class ==
  
In this wiki, creating a class is done by an admin.  Go to [[Special:SpecialPages]] and find the link for creating a class.  The convention is to name *fields* with noun-like names like "something" and *properties* with verb-like names "Has something" or "Is something.   
+
In this wiki, creating a class is done by an admin.  Go to [[Special:SpecialPages]] and find the link for creating a class.  The convention is to name '''fields''' with noun-like names like '''''something''''' and '''properties''' with verb-like names '''''Has something''''' or '''''Is something'''''.   
  
The field names are what are used when calling the template that defines the object instance of the class.  The property names are what are used later to query these objects.
+
The ''field'' names are what are used when calling the template that defines the object instance of the class.  The ''property'' names are what are used later to query these objects.
  
Pick the same name for the template, form and category and do not check the box about including multiple times on the page.  Pick a default output format as seems best suited.
+
Pick the same name for the ''template'', ''form'' and ''category'' and do not check the box about including multiple times on the page.  Pick a default output format as seems best suited to the class you are creating.
  
When naming and populating the fields and properties, keep in mind how instances of this class may relate to others that exist or are expected in the future.  Following consistent naming conventions helps.  In particular, reuse existing property names if they match conceptually.
+
When naming and populating the fields and properties, keep in mind how instances of this class may relate to others that exist or are expected in the future.  Following consistent naming conventions helps humans form connections later in queries.  In particular, reuse existing property names if they match conceptually.
  
 
== Properties ==
 
== Properties ==

Latest revision as of 14:22, 27 October 2014

Use of Semantic MediaWiki extensions in this wiki

General

SMW adds the idea of named properties to MediaWiki. These are generally organized into a "class" similar in concept to a class in the Object-Oriented programming paradigm. A class consists of:

  • A set of associated parameters making up the "object" instance of a class
  • A form to create and edit instances
  • A category to collect all instances of a particular class
  • Some views into of a subset of a classes parameters and possibly across a collection of objects

Creating a class

In this wiki, creating a class is done by an admin. Go to Special:SpecialPages and find the link for creating a class. The convention is to name fields with noun-like names like something and properties with verb-like names Has something or Is something.

The field names are what are used when calling the template that defines the object instance of the class. The property names are what are used later to query these objects.

Pick the same name for the template, form and category and do not check the box about including multiple times on the page. Pick a default output format as seems best suited to the class you are creating.

When naming and populating the fields and properties, keep in mind how instances of this class may relate to others that exist or are expected in the future. Following consistent naming conventions helps humans form connections later in queries. In particular, reuse existing property names if they match conceptually.

Properties

A property is like a generalized form of a category. A property has a page which contains a special property written like [[Has type::THE TYPE NAME]]. When creating properties through the class mechanism above this is all taken care of for you but if you wish to add new properties you need to know this detail.

A property can be "made" out of thin air just by writing it in any page like [[The property name::THE PROPERTY VALUE]]. By default, properties are of type "page". This can be set or changed by editing the page that is created for "The property name" and either hand-editing the "Has type" value or if it has not yet been created using "Create with form" and choosing the type from the drop-down list.

Property names are case sensitive. It is recommended to keep to a consistent case convention. Along with the convention of taking on verb-like names, here are some examples:

  • Has name
  • Has url
  • Is owned by
  • Is capital of

Queries

The main use of adding properties to pages is to query them in various ways.

Inline queries let you "ask" for a collection of matching pages or "show" single value from a parameter in one page.

Result formats

Result formats may be specified in an inline query in order to influence how the result of the query is displayed. For example, an "ask" query defaults to a table but by specifying the "ul" one gets instead an unordered list. Elaborate result formats are included or available as extensions. For example a collection of pages with a date property can be displayed either as an list ordered by date, a calendar or a timeline.