Help:List of datatypes

From semantic-mediawiki.org
Jump to: navigation, search
Table of Contents

Using different datatypes, properties can be used to describe very different kinds of values. A complete list of all 16 datatypes provided by Semantic MediaWiki and 1 provided by other semantic extensions is available from special page "Types". The available 17 datatypes are:

DatatypeDescriptionIDHelp pageProvided by
Annotation URIHolds URIs, but has some technical differences during export compared to the "URL" type
_anu
Help:Datatype "Annotation URI"Semantic MediaWiki
BooleanHolds boolean (true/false) values
_boo
Help:Datatype "Boolean"Semantic MediaWiki
CodeHolds technical, pre-formatted texts (similar to type Text)
_cod
Help:Datatype "Code"Semantic MediaWiki
DateHolds particular points in time
_dat
Help:Datatype "Date"Semantic MediaWiki
EmailHolds e-mail addresses
_ema
Help:Datatype "Email"Semantic MediaWiki
External identifierHolds a value that associates it with with a external URI for formatting
_eid
Help:Datatype "External identifier"Semantic MediaWiki
Geographic coordinateHolds coordinates describing geographic locations
_geo
Help:Datatype "Geographic coordinate"Maps (Semantic Maps)
Monolingual textHolds a text value that associates the annotation with a specific language code
_mlt_rec
Help:Datatype "Monolingual text"Semantic MediaWiki
NumberHolds integer and decimal numbers, with an optional exponent
_num
Help:Datatype "Number"Semantic MediaWiki
PageHolds names of wiki pages, and displays them as a link
_wpg
Help:Datatype "Page"Semantic MediaWiki
QuantityHolds values that describe quantities, containing both a number and a unit
_qty
Help:Datatype "Quantity"Semantic MediaWiki
RecordHolds compound property values that consist of a short list of values with fixed type and order
_rec
Help:Datatype "Record"Semantic MediaWiki
Telephone numberHolds international telephone numbers based on the RFC 3966 standard
_tel
Help:Datatype "Telephone number"Semantic MediaWiki
TemperatureHolds temperature values (similar to type Quantity)
_tem
Help:Datatype "Temperature"Semantic MediaWiki
TextHolds text of arbitrary length
_txt
Help:Datatype "Text"Semantic MediaWiki
ReferenceHolds a value that associates it to individual defined provenance metadata record
_ref_rec
Help:Datatype "Reference"Semantic MediaWiki
URLHolds URIs, URNs and URLs
_uri
Help:Datatype "URL"Semantic MediaWiki

Example values and formatting

Datatype Property Example value Query display Query display using #- (plain)
Annotation URI Property:Has annotation uri http://www.semantic-mediawiki.org http://www.semantic-mediawiki.org http://www.semantic-mediawiki.org
Boolean Property:Has boolean true true true
Code Property:Has code
Code
is preserved but macros are expanded. E.g:
Help:List of datatypes
is displayed as the name of this page instead of FULLPAGENAME
Code
is preserved but macros are expanded. E.g:
Help:List of datatypes
is displayed as the name of this page instead of FULLPAGENAME
Code
is preserved but macros are expanded. E.g:
Help:List of datatypes
is displayed as the name of this page instead of FULLPAGENAME
Date Property:Has date 2015-05-22T17:32 22 May 2015 17:32:00 2015-05-22T17:32:00
External_identifier Property:Has Wikidata item ID Q9439 Q9439 Q9439
EMail Property:Has email address president@whitehouse.gov president@whitehouse.gov president@whitehouse.gov
Geographic coordinate Property:Has coordinates 32° 42' 54", -117° 9' 45" 32° 42' 54", -117° 9' 45" 32° 42' 54", -117° 9' 45"
Number Property:Has number 47000.11 47,000.11 47000.11
Page Property:Has example Semantic MediaWiki Semantic MediaWiki Semantic MediaWiki
Quantity Property:Area 1052km²
406.177 sqmi
1,052 km²
406.177 sqmi
1052 km²
Record Property:Soccer result 22 March 2015 (Bayern München, Borussia Mönchengladbach, 0, 2) 22 March 2015 (Bayern München, Borussia Mönchengladbach, 0, 2) 22 March 2015 (Bayern München, Borussia Mönchengladbach, 0, 2)
Telephone number Property:Telephone number +1-800-225-5288 +1-800-225-5288 +1-800-225-5288
Temperature Property:Has temperatureExample 23°C
296.15 K
73.4 °F
533.07 °R
296.15 K
23 °C
73.4 °F
533.07 °R
296.15 K
Text Property:SomeProperty Did you create the page for Tokyo 東京 ? Yes ✓ Did you create the page for Tokyo 東京 ? Yes ✓ Did you create the page for Tokyo 東京 ? Yes ✓
URL Property:Has_URL http://www.whitehouse.gov http://www.whitehouse.gov http://www.whitehouse.gov

Enumerations and "Allows value"

In addition to assigning a datatype to a property, you can also restrict the allowed values to a given set (like a whitelist for property inputs). This is done by using the special property Property:Allows value to enumerate its permitted values. This works for every datatype.

Units

The datatype Quantity allows a unit after the numeric value to distinguish values (e.g. "30 miles" versus "42 km"). To support automatic conversion and multiple unit formats, one needs to declare each supported unit as described in the documentation on Custom units. Property values are then automatically converted between different units, so that users are free to use their preferred unit in each article yet still query and compare with property values in other articles.

Handling in earlier versions

Up to Semantic MediaWiki 1.5.6, datatypes had individual wiki pages in their own namespace called "Type". This was abolished to reduce the number of extra namespaces. You may still find expressions like "Type:Number" in places in this wiki. Both writings are accepted for assigning a datatype to a property.

In very early versions of SMW, properties with datatype Page were known as relations and only those used double colons (::) as the separator between property name and link text. All other properties (numbers, text, etc.) were known as attributes and had to use colon equals (:=) as the separator.

See Upgrading from SMW 0.7 to SMW 1.0 for other changes in SMW 1.0; if you're still using the older version of SMW, see semweb:Help:Annotation (SMW0.7) for documentation of Annotations in version 0.7.