Archive:Fixed properties 1.8.x

From semantic-mediawiki.org
Table of Contents

This page provides information about fixed properties which were introduced to Semantic MediaWiki in version 1.8.0.

Introduction[edit]

The new SQL Store in SMW (SQLStore3) has the new feature called fixed properties. Fixed properties are properties used heavily in a wiki which use a dedicated database table. For example a wiki about people will have a property called "Age" used extensively within the wiki. To optimize operations on this property there is support to have property-value tuples of these properties stored in a separate dedicated database table rather than in the generic table used for their datatypes.

This feature is still experimental and needs some testing. If you are able to produce some performance gain using this feature please refer to it on this page's talk page.

Usage[edit]

To use this feature you must be using SQLStore3. To use this, you can add a new entry in the fixedProperties array in the SMWSQLStore3.php file as a key => value pair, where the key is the property name used in the wiki (but with " " replaced with "_" and the first letter capitalized), and the value is the constant used to denote properties of this type in class SMWDataItem, this will be one of the following:

		SMWDataItem::TYPE_BLOB // properties of type text and code
		SMWDataItem::TYPE_URI // properties of type email, telephone number, URL and annotation URI
		SMWDataItem::TYPE_WIKIPAGE // properties of type page
		SMWDataItem::TYPE_NUMBER // properties of type number and quantity
		SMWDataItem::TYPE_TIME // properties of type date
		SMWDataItem::TYPE_BOOLEAN // properties of type boolean
                SMWDataItem::TYPE_CONTAINER // properties of type record
		SMWDataItem::TYPE_GEO // properties of type geographic coordinates

A run of setup using SMWAdmin is needed to create these tables. If an already used property is assigned a new table all old data for this property will become inaccessible for SMW. This can be repaired by either migrating it to the new table or will eventually be updated on page edits.

Examples[edit]

An example of an entry in the fixedProperties array would look like

public static $fixedProperties = array(
        'Age' => SMWDataItem::TYPE_NUMBER
);

where "Age" is a property of type "Number".

Note that this feature is not upgrade proof, i.e. as soon as you replace SMWSQLStore3.php during each update of you wiki you will have to add your fixed property to the fixedProperties array again.

Developer Section[edit]

This section is proposed to be moved to a separate page within Category:Developer documentation

The name of the database table is formed using md5

$tableName = 'smw_fpt_' . md5( $propertyKey );

See also[edit]


This documentation page applies to all SMW versions from 1.8.0 to 1.8.x.
Other versions: 1.9.0 – 2.4.x      

Fixed properties en 1.8.0 1.8.x