Album-to-song and tracklists relationships

From semantic-mediawiki.org

To build a one-to-many relationship for a subject (e.g. Album entity) it would be best to use the #subobject instead of #set.

{{#subobject:
 |Type=tracklist
 |Collection={{FULLPAGENAME}}
 |Version={{{Version|}}}
 |Index={{#var: I}}
 |Song={{#var: V}}
}}
{{#ask: [[Collection::{{FULLPAGENAME}}]]
 |?Version
 |?Index
 |?Song
 |mainlabel=-
}}

See also Examples/Queries/Subobject to display table rows

> music band wiki. I'm going to start a new project and now

You may want to look at [0] to get some ideas about a music related wiki that uses SMW.

[0] http://tangowiki.org/wiki/Main_Page

19:38, 25 June 2015

This is interesting. I'm currently testing it, and it seems to be what I want. Thank you!

10:08, 28 June 2015
 

One more question, please. Is it possible to refer the properties defined at the "sub/child"-pages? I would like to extend the above template/table output with the "Length" column so it could look like a real tracklist. The ?Song property refers to song pages, and every song page has a song definition with the Length property set. It's like the INNER JOIN operation, but I feel like I'm abusing SMW capabilities (and it looks like I'm more of finding a search mechanism like XPath). Is it possible somehow?

20:16, 28 June 2015

In case you go with the #subobject then your data model will most likely be something like:

  • An ALBUM is represented by a wikipage ->
  • Subobjects are embedded in a page to represent each individual song ->
  • Each song has attributes like:
    • Song title
    • Song index
    • Song length
    • Song author/composer/writer (optional in case it is a compilation where a song can have different writers from the Album)
    • etc.

As demonstrated you attach attributes/properties to an individual song which a #subobject not a page (we are talking about an entity)

If you want to split an ALBUM/SONG by page/subpage then you can take a similar approach only that subobjects need to contain a reference to the album.

For example, looking for an album of song writer YYY where you want to see songs with title and length -> [[Has song writer::YYY]]|?Song title|?Song length.

15:02, 7 July 2015

It sounds promising. I'll try your suggestion as soon as possible. Thank you very much!

18:59, 13 July 2015