Help:SemanticData

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

To represent semantic information, dataitems need to be combined into facts. For this purpose, the class SemanticData provides a basic container for handling sets of facts that refer to the same subject. This makes sense since it is by far the most common case that the subject is the same for many facts (e.g. all facts on one page, or all facts in one row of a query result).

A SemanticData container further groups values by property: it has a list of properties, and for each property a list of values. Again this reflects common access patterns and avoids duplication of information. The data contained in SemanticDatacan still be viewed as a set of subject-property-value triples, but SMW has no dedicated way to represent such triples, i.e. there is no special class for representing one fact.

SMW generally uses SemanticDatawhenever sets of triples are needed. If many subjects are involved, then one may use an array of SemanticDataobjects. In other cases, one only wants to consider a list of SMWDataValues (Introduced below) instead of whole facts, e.g. when fetching the list of all pages that are annotated with a given property-value pair (e.g. all things located in France). In this case, the facts are implicit (one could combine the query parameters "located_in" and "France" with each of the result values). Another important case are query results. They have their own special container class SMWQueryResult which is similar to a list of SMWSemanticData containers for each row, but has some more intelligence to fetch the required data only on demand (implementation detail, but part of the raison d'etre for this class).

ContainerSemanticData ...