[Semediawiki-user] Defining n-ary relations From: Yaron Koren - 2007-04-15 19:21 Attachments: Message as HTML ```Hi, We might as well have a direct discussion about defining n-ary relations in SMW. This came up in an email thread on March 27, and a few suggestions wer= e raised; let me first go through the suggestions people had (I changed aroun= d some of the data for the sake of consistency between examples), and then I'll present my own suggestion. The examples are all for a hypothetical pag= e about the United States, that lists its presidents. Markus suggested: [[has president::Bush; 2001; 2008]] G=FCnther suggested something like: [[has president::Richard Nixon; 1969; [[end of term:=3Dresignation; 9 Augus= t 1974; ; Watergate scandal]] ]] These are simple solutions that are similar, I believe, to how BOWiki does it (though I don't think BOWiki's allows for recursiveness). The problem I see with these (and with BOWiki's) is that they don't define the data; there's no identifier for the relation of most of these sub-fields. Also, there's no indication of how the data is to be displayed on the page. MovGP0 suggested something like: [[has president:: [[Person::Richard Nixon]] began his term in [[start of term:: [[Year::1969]] ]] but [[end of term:: [[Reason:: [[Type::resignation|resigned]] because of the [[Because::Watergate scandal|]] on [[Date:=3D1974-08-09|August 9, 1974]] ]] ]] This is, I believe, a better solution, since it gives a relation to each piece of data, and specifies the display of the data as well. However, it's recursive, and I don't think there's a need for recursiveness in defining relations: if Richard Nixon is important enough to the wiki that his reason for resigning needs to be included, then he or his presidency should probably have their own page, with the reason placed there (or, if there's more data, maybe even his *resignation* should have its own page). Allowing infinite recursiveness would let you, in theory, place all the data of a wiki onto a single page, which I don't think is a good use of the technology. Here, then, is my suggested version: [[[Has president:: [[Has name::Richard Nixon]] began his term in [[Start of term::1969]] and ended his term in [[End of term::1974]] due to a [[Reason for end::Resignation]] ]]] All the data is no more than one level down. Note, also, the triple bracket= s that define the main relation. I think it's important to use a tag other than the usual double-brackets for n-ary relations, for two reasons: first, double brackets so far have been used to define a single item, not a free-form area, and second, using another tag would clarify that only two levels of relations are allowed. I picked triple brackets because it's the next logical step after double brackets, but any other type of tag could work as well. As for the database implementation, it could be pretty simple. There could be another column in the tables 'smw_relations' and 'smw_attributes' (or whatever table replaces both of them, if that happens) called, say, "subject_section_num". For regular relations/attributes, this column would be null (or 0). For a property that's part of an n-ary relation, it would b= e the index of that n-ary relation; the first one on the page would have the value of "1", etc. This index would be used in defining those relations in the RDF export, and could also be used to group relations for internal semantic searching. Any thoughts on this? -Yaron ```
 Re: [Semediawiki-user] Defining n-ary relations From: Michael Backhaus - 2007-04-16 10:33 ```Hi, On 15.04.2007, at 21:21, Yaron Koren wrote: > The problem I see with these (and with BOWiki's) is that they don't > define the data; there's no identifier for the relation of most of > these sub-fields. In BOWiki so called 'roles' are used to specify the part an object has in a certain relation. Roles structure the arguments in a n-ary relation, which allows an arbitrary order, while it also allows to order the arguments, for example in case of further reasoning. Roles are declared in a relation, using the following syntax: [[relation::role=object]] Further, n-ary relations are represented in the BOWiki by instantiaion of relations, which is conform with the suggestion of the W3C (http://www.w3.org/TR/swbp-n-aryRelations/). The ID of the relation instance is used to store and restructure the objects of a relation in the wiki and database. In the DB of the Semantic MediaWiki, a suggestion would be to use relation instantiation (perhaps in another table), while the smw_relations table could be extended by one column to hold the relation_instance_id, allowing to restructure n-ary relations by changes to the necessary smw functions. An example like the one suggested by MovGPO and Yaron could be writen by using roles: [[has president::Person=Richard Nixon; start of term=1969; end of term=1974; reason for end=Watergate scandall]] Although this would treat the years 1969 and 174 as objects, which could be a matter of conception, it would allow for an interesting semantic search on all 'reason for end', or even an inline querry listing all persons that have been president including start and end term, reason, etc. Cheers, Michael ```
 Re: [Semediawiki-user] Defining n-ary relations From: Yaron Koren - 2007-04-16 17:12 Attachments: Message as HTML ```That's interesting. But where is the display of the data defined? -Yaron On 4/16/07, Michael Backhaus wrote: > > Hi, > > On 15.04.2007, at 21:21, Yaron Koren wrote: > > The problem I see with these (and with BOWiki's) is that they don't > > define the data; there's no identifier for the relation of most of > > these sub-fields. > > In BOWiki so called 'roles' are used to specify the part an object > has in a certain relation. Roles structure the arguments in a n-ary > relation, which allows an arbitrary order, while it also allows to > order the arguments, for example in case of further reasoning. Roles > are declared in a relation, using the following syntax: > > [[relation::role=object]] > > Further, n-ary relations are represented in the BOWiki by > instantiaion of relations, which is conform with the suggestion of > the W3C (http://www.w3.org/TR/swbp-n-aryRelations/). The ID of the > relation instance is used to store and restructure the objects of a > relation in the wiki and database. > > In the DB of the Semantic MediaWiki, a suggestion would be to use > relation instantiation (perhaps in another table), while the > smw_relations table could be extended by one column to hold the > relation_instance_id, allowing to restructure n-ary relations by > changes to the necessary smw functions. > > An example like the one suggested by MovGPO and Yaron could be writen > by using roles: > > [[has president::Person=Richard Nixon; start of term=1969; end of > term=1974; reason for end=Watergate scandall]] > > Although this would treat the years 1969 and 174 as objects, which > could be a matter of conception, it would allow for an interesting > semantic search on all 'reason for end', or even an inline querry > listing all persons that have been president including start and end > term, reason, etc. > > Cheers, > > Michael > ```
 Re: [Semediawiki-user] Defining n-ary relations From: Michael Backhaus - 2007-04-16 17:52 ```On 16.04.2007, at 19:12, Yaron Koren wrote: > That's interesting. But where is the display of the data defined? The n-ary relations are represented on the wiki-page in the same way as the triple-relations, by listing all objects and eventually existing roles according to a relation(-instance), with links to the according concepts. Also the n-ary relations are displayed in the infobox, from where searches with the search tuple can be triggered. Most of the display functions are defined in SMW_SemanticData.php, which has been modified in the BOWiki. I hope that i could answer your question. Cheers, Michael ```
 Re: [Semediawiki-user] Defining n-ary relations From: Yaron Koren - 2007-04-17 16:57 Attachments: Message as HTML ```Okay, I think I understand. In other words, n-ary data appears on the page in some sort of pre-set format. A user couldn't set the text to read, say, "Richard Nixon was President from 1969 to 1974; his term ended due to the Watergate Scandal" (with some of the words in that sentence being wiki-links). Personally, I think pre-set formatting is fine for a specialized site like BOWiki, but it might not be ideal as a general solution for all wikis. But this approach certainly takes care of defining those internal relations. I'm curious what other people think. -Yaron On 4/16/07, Michael Backhaus wrote: > > On 16.04.2007, at 19:12, Yaron Koren wrote: > > That's interesting. But where is the display of the data defined? > > The n-ary relations are represented on the wiki-page in the same way > as the triple-relations, by listing all objects and eventually > existing roles according to a relation(-instance), with links to the > according concepts. Also the n-ary relations are displayed in the > infobox, from where searches with the search tuple can be triggered. > Most of the display functions are defined in SMW_SemanticData.php, > which has been modified in the BOWiki. > I hope that i could answer your question. > > Cheers, > > Michael > ```