Semanticmediawiki: Question - Record in Record, #ask, (data retrieval on elements in sub-record)?

Created on 8 Sep 2018  路  4Comments  路  Source: SemanticMediaWiki/SemanticMediaWiki

Setup and configuration

  • SMW version: 2.5.6
  • MW version: 1.31.0
  • PHP version: 7.0.30-0+deb9u1 (fpm-fcgi)
  • DB system (MySQL, Blazegraph, etc.) and version: 10.1.26-MariaDB-0+deb9u1

Background

Playing around with Records to see how it works in practice and where the boundaries are.
At some point the idea of a record inside a record came up (_data based inspired_).
Setting it up was the easy part. Just including a record-type inside the Has_Fields of an other Record-type did the job.
Saving data to it took a little bit more reading/thinking. But escaping the correct field delimited in the #set command did that job.
But ... the last part, retrieving individual record data on the sub-record so far has eluded me. Figure it might actually not be possible to do that directly with an #ask query. Ergo ...

Question

Is it somehow possible (or completely impossible/currently unsupported) to directly retrieve a single data element, on a record that is included in an other record, by way of an #ask query ?
(_ie: getting only "456" or "789" as #ask output?_)

Steps to reproduce

_Property pages_:

  • Test_Record: [[Has type::Record]], [[Has fields::Test_Value; Test_Record_1]] - (Main Record)
  • Test_Value: [[Has type::Number]]
  • Test_Record_1: [[Has type::Record]], [[Has fields::Test_Value_1; Test_Value_2]] - (Sub Record)
  • Test_Value_1: [[Has type::Number]]
  • Test_Value_2: [[Has type::Number]]

_Data Input_:

  • {{#set:Test Record= 123; 456\; 789}} <= _! second delimiter is escaped (tiny char, easily overlooked)_

_(known) Date Retrieval_:

  • Full "Test_Record" => {{#ask: [[Test Record::+]] |?Test Record}} => "123(456 (789))"
  • "Test_Value" data => {{#ask: [[Test Record::+]] |?Test Record=v0|+index=1}} => "123"
  • "Test_Value_1" data => {{#ask: [[Test Record::+]] |?Test Record=v1|+index=2}} => "456 (789)"

Local resolution (_in case of silence_)
Figure the Record-type property is also some "special purpose query formats" and as such falls under its own limitations.

(_Ps: "... etc." is nice, for those that already know what it entails. For new-users to a particular app, its might not be so helpful. ... Just a thought._)

question

Most helpful comment

I have never seen that syntax/usage before.

FYI, i've update the docs on Record type to explain also this capability:
https://www.semantic-mediawiki.org/w/index.php?title=Help:Type_Record&oldid=66118

All 4 comments

Is it somehow possible (or completely impossible/currently unsupported) to directly retrieve a single data element

What about?

{{#ask: [[Test Record::+]] |?Test Record.Test_Record_1.Test_Value_1}} --> should print 456
{{#ask: [[Test Record::+]] |?Test Record.Test_Record_1.Test_Value_2}} --> should print 789

PS: Would be nice if could recreate your example on the sandbox.

I have never seen that syntax/usage before.
...
Aha. So that's what its called, a "property chain".
So far I only found two SMW pages that talk, or even hint, towards that particular usage.
...
But ... Yep. Its working.
Also solved that big question mark that was hanging over "How to #Show specific elements on normal-records" on this side.

Needless to say. Good docs ... Saves time (and other stuff) ... on both sides.

...

Thanks for info anyway. :-)

So far I only found two SMW pages that talk, or even hint, towards that particular usage.

This feature came with #1824, applicable to all page type properties (those that represent a resource or in wiki terms a link).

@kghbln FYI

I have never seen that syntax/usage before.

FYI, i've update the docs on Record type to explain also this capability:
https://www.semantic-mediawiki.org/w/index.php?title=Help:Type_Record&oldid=66118

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SteveRMann picture SteveRMann  路  4Comments

JeroenDeDauw picture JeroenDeDauw  路  3Comments

mwjames picture mwjames  路  3Comments

mwjames picture mwjames  路  3Comments

WolfgangFahl picture WolfgangFahl  路  3Comments