Album-to-song and tracklists relationships
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.
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?
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.