Help:Data Storage

As the wiki includes more and more information, it becomes useful to consider other ways to handle information than just categorizing pages in Categories.

This guide will assume you are familiar with Namespaces (ie "File:", "User:", "Template:", "Category:", etc.) and Categories (ie Category:Characters). It will primarily cover Properties and Concepts, and a little bit of Parser Functions (namely, the inline queries #show and #ask ).

Properties
 A holds data for a page (a "property" of the page) that can be used on another page with a few lines of text, or to "categorize" a page (see Concepts), or to sort pages. 
 * To set a property of a page.
 * To set a property of a page, while leaving a link to the property value.
 * To set multiple properties of a page at once. You can also set the same property multiple times to different values (e.g. Eye Color to Green and Blue).
 * To show the property's value for that page.
 * To get all pages with the Property set to that property value (in a table)


 * Read more about #show and #ask

Properties have pages prefixed by "Property". You can see all properties that currently exist on the wiki, and all properties with a page (change the Namespace dropdown to "Property"). Properties without a page are usually added automatically by software, whereas properties with a page are usually created by users.

Note that the properties talked about here (the namespace and functionality provided by Semantic MediaWiki) are different from the "page properties" listed on the Special:Pages With Properties page.

Properties vs Categories

 * Properties are "hidden" from viewers of a page, whereas Categories which are "shown" (at the bottom of the page).
 * Properties are more flexible than Categories, and are well-suited for use with Templates, Modules (Scripts), Parser Functions, and other advanced topics, although Categories can be used for these purposes as well.

Semantic MediaWiki has dedicated a whole page to this.

Usage
To illustrate this, let's say we want the "color of a character's eyes" to be a Property. Following the suggested style of naming, we'll call this property "Has eye color" (as in, Ragna the Bloodedge "has [the] eye color" green).

Setting Properties

 * 1. On Ragna's page, we can say his eyes are green by writing:


 * 2. Since Ragna has two colors for his eyes (one color for each), we put a "|" and add his second eye color afterwards:
 * This gives the page for Ragna the Bloodedge the Property "Has eye color" twice, once for "Green" and once for "Red". Or, we could say it sets the property twice to those values. Ragna the Bloodedge now "Has eye color" green and red.
 * This gives the page for Ragna the Bloodedge the Property "Has eye color" twice, once for "Green" and once for "Red". Or, we could say it sets the property twice to those values. Ragna the Bloodedge now "Has eye color" green and red.

Getting Properties

 * 3. You can get Ragna's eye colors (i.e. print it) on any page with:
 * This will show what was set for the property "Has eye color" for the page "Ragna the Bloodedge". The "?" before the Property is to say that "Has eye color" is a property (as opposed to a Category or a page).
 * * For more details on #show, see here.
 * * For more details on #show, see here.


 * 4. Alternatively, you can use what is called an Inverse Property to get Ragna's eye colors with:
 * However, this is hard to read, and it only retrieves pages. In this case, if "Green" and "Red" do not have pages, then writing the above will not work. (An example of a better usage would be something like, which can be imagined to return  , which does have a page.)
 * However, this is hard to read, and it only retrieves pages. In this case, if "Green" and "Red" do not have pages, then writing the above will not work. (An example of a better usage would be something like, which can be imagined to return  , which does have a page.)

Getting Pages with a Certain Property

 * 5. You can also gather a list of all pages with a property (displayed in a table) using #ask :


 * In this example Located in::Germany, ?Population, and ?Area all define the use of Properties - specifically, the "Located in," "Population," and "Area" properties. In the above example, #ask will ask for all the pages that are Located in::Germany (have the "Located in" Property set to "Germany") and are categorized as cities (in the category "City"). It will then display the Population and Area properties of each page that fits those criteria. By default, this is displayed in a table.
 * * For more details about the above example and what else can be done with #ask, see here)


 * 6. You can also get a list of all pages with a property by using a Concept (see Concepts below).

Creating Pages for Properties
On the property's page, be sure to include somewhere its type with something similar to. See Semantic MediaWiki's page on Property declaration for what types are available and more details.

Reference Links
Properties are part of the Semantic MediaWiki extension. For more details, you can refer to the Semantic MediaWiki's Properties page.


 * MediaWiki, Extension: Semantic Mediawiki
 * Semantic MediaWiki, Help: Properties and types
 * Semantic MediaWiki, Properties (types of Properties)
 * Semantic MediaWiki, Inverse Properties
 * Semantic MediaWiki, Parser Functions
 * Semantic MediaWiki, Inline Queries (#show, #ask)

Concepts
 A is a page that is created in the Concept namespace, which defines a "dynamic category." 


 * Read the manual for Concepts

Why Use Concepts?

 * They can be used to define a "pseudo-category" that doesn't need an explicit category page, but would be nice to have as a logical group.
 * For example, "Staff Extras drawn by Toshimichi Mori." We have the category Staff Extras and the category Mori, Toshimichi, but it would be overkill (and difficult to maintain) if we were to try to define a third category "Staff Extras by Mori Toshimichi" to determine the two categories' intersection.
 * With a concept, you only need to create a page "Concept:Staff Extras Drawn By Toshimichi Mori" and write the query for the concept inside. Then, you will be able to view the concept's page the same way you can view a category's page, and see all the pages gathered in that concept.


 * They can be used to create a Page Form ("forms to add and edit wiki pages"). A Page Form defines a form that just needs to be filled out to create a complex page. Concepts can be used to define a list of possible values for a field on the form (for example, valid categories to categorize the page with). For more details, see Semantic MediaWiki's pages on Page Forms and Concepts.
 * They can be used with inline queries (like #show and #ask).

Usage
Please refer to the Semantic MediaWiki's page on Concepts.

Reference Links
Concepts are part of the Semantic MediaWiki extension. For more details, you can refer to the Semantic MediaWiki's page on concepts.


 * Semantic MediaWiki, Concepts
 * Semantic MediaWiki, Page Forms
 * MediaWiki, Defining the 'field' tag of Page Forms

Cargo
 ''Cargo is an extension to MediaWiki that provides a lightweight way to store and query the data contained within the calls to templates, such as infoboxes. It is similar in concept to the Semantic MediaWiki extension, but offers a number of advantages, including ease of installation and ease of use.''  The extension defines a number of parser functions; these three are the most important: The other defined parser functions are:  - MediaWiki, Extension:Cargo 
 * - placed within the part of a template; it defines the schema for a table.
 * - stores one row to a Cargo table; usually placed within the part of a template.
 * - queries one or more Cargo data tables, using SQL components.
 * - defines a template as adding rows to a table declared elsewhere.
 * - displays the results of multiple queries in one place.
 * - displays a map showing a single point.
 * - prints out the dates for a recurring event; for use by #cargo_store.

Cargo is like a mini database. It is meant to be used with templates, and specifically infoboxes, (e.g. Character Infoboxes). Cargo inserts each field of the infobox (EN name, JP name, romaji, eye color, height, birthday, etc) into a "database" for the page that template is included on.

Simply put, the page "Ragna the Bloodedge" can become connected to the values "Ragna the Bloodedge" as his English name, "ラグナ＝ザ＝ブラッドエッジ" as his Japanese name, "March 3rd" for his birthday, "Artificial Human" for his species, and so on and so forth.

Why Use Cargo?

 * It keeps pages cleaner and more consistent by defining all "properties" on a template page.
 * Using Cargo is purportedly simpler (in templates, etc) than using Semantic MediaWiki (and its Properties and Concepts).
 * Just the one Cargo extension can take the place of several others to provide the same functionality.
 * Cargo is best used for infoboxes that define a set of values that won't change often, and do not have many unknowns about what could be in the value (for example, if there will be references or links included, or if you'll be using DD/MM/YYYY instead of MM/DD/YYYY). For example, unit data (stats, skills, unit types, rarity).

Cargo vs. Semantic MediaWiki (Properties and Concepts)
MediaWiki's page on Cargo and Semantic MediaWiki gives us this:

Philosophically, Cargo differs from SMW in three main ways: 
 * Cargo ties data storage directly to templates. In SMW, semantic values can be placed anywhere on the page, even though in practice they're usually confined to templates; but in Cargo, it is the template itself that is responsible for storing its data.
 * Cargo stores its data in as simple a fashion as possible, using standard database tables to hold tabular data; while SMW uses a database to represent "triples" of data.
 * Though this is a more minor difference, Cargo is less customizable than SMW and its spinoff extensions, opting instead to base display settings on the data itself.