{"id":588,"date":"2020-01-21T09:56:52","date_gmt":"2020-01-21T09:56:52","guid":{"rendered":"http:\/\/wikidata.wwwnlsrc4.supercp.com\/?p=588"},"modified":"2020-11-22T13:37:21","modified_gmt":"2020-11-22T13:37:21","slug":"property-paths","status":"publish","type":"post","link":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/simple-queries\/instances-and-classes\/property-paths\/","title":{"rendered":"Property paths"},"content":{"rendered":"\n<h2>Property paths<\/h2>\n\n\n\n<p>The query construction that allows us to select items that belong to the same class makes use of property paths. Property paths are shorthand for writing down a path of properties between two items.&nbsp; <\/p>\n\n\n\n<p>To understand how this construction works, take a look at the graphic view of some information about the item Star Wars: Episode I \u2013 The Phantom Menace&nbsp;(Q165713):<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" width=\"771\" height=\"392\" src=\"https:\/\/wdqs-tutorial.toolforge.org\/wp-content\/uploads\/2020\/01\/instance-and-subclass-1.png\" alt=\"\" class=\"wp-image-622\" srcset=\"https:\/\/wdqs-tutorial.toolforge.org\/wp-content\/uploads\/2020\/01\/instance-and-subclass-1.png 771w, https:\/\/wdqs-tutorial.toolforge.org\/wp-content\/uploads\/2020\/01\/instance-and-subclass-1-300x153.png 300w, https:\/\/wdqs-tutorial.toolforge.org\/wp-content\/uploads\/2020\/01\/instance-and-subclass-1-768x390.png 768w\" sizes=\"(max-width: 771px) 100vw, 771px\" \/><\/figure><\/div>\n\n\n\n<p>Item Q165713 has a P31 (instance of) statement with &#8220;feature film&#8221; (Q24869) as its value. So the Item-Property-Value statement would be:<\/p>\n\n\n\n<p>Q165713 \u2013 P31 \u2013 Q24869<\/p>\n\n\n\n<p>The path between Q165713 and Q24869 is the simplest path: a single property.<\/p>\n\n\n\n<p>Item Q24869 (feature film) has the property P279 (subclass of) with the value Q11424 (film). So the Item-Property-Value statement would be: <\/p>\n\n\n\n<p>Q24869  \u2013 P279 \u2013  Q11424<\/p>\n\n\n\n<p>The path between Q24869 and Q11424 is also just a single property.  <br><\/p>\n\n\n\n<p>Path elements can be put together with a forward slash (<code>\/<\/code>). So a query statement that uses the construction <strong>wdt:P31\/wdt:P279<\/strong> denotes a property path between two items consisting of P31 (instance of) and P279 (subclass of). <\/p>\n\n\n\n<p>However, if our pattern for matching would be:<br>?item wdt:P31\/wdt:P279 wd:Q11424.<br>the query would match <strong>only <\/strong>items that are an instance of a subclass of film, meaning only items that have a path consisting of P31 <strong>and <\/strong>P279 to the item film (Q11424). Items whose P31 property has the value Q11424 would <strong>not <\/strong>be retrieved, because they do not match the construction pattern.<\/p>\n\n\n\n<iframe class=\"\" src=\"https:\/\/query.wikidata.org\/#%23Star%20Wars%20films%0A%0ASELECT%20%20%3Fitem%20%20%3FitemLabel%20%20%0AWHERE%20%0A%7B%20%0A%20%20%3Fitem%20wdt%3AP31%2Fwdt%3AP279%2a%20wd%3AQ11424.%20%23item%20is%20an%20instance%20of%20film%20or%20of%20a%20subclass%20of%20film%0A%20%20%3Fitem%20wdt%3AP1434%20wd%3AQ19786052.%20%20%20%20%20%20%23item%20takes%20place%20in%20fictional%20universe%20of%20Star%20War%20universe%20%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%22.%20%7D%0A%7D\" style=\"width:100%;max-width:100%;height:450px\" frameborder=\"0\"><\/iframe>\n\n\n\n<p>The construction <strong>wdt:P31\/wdt:P279*<\/strong> on line 6 is shorthand for saying that there\u2019s an \u201cinstance of\u201d property and then <span style=\"text-decoration: underline;\">any number<\/span> of \u201csubclass of\u201d properties between ?item and the item &#8220;film&#8221; (Q11424). <\/p>\n\n\n\n<p>If you remove the asterisk (<code>*<\/code>) on line 6 of the query above and run the query again you will see that the query does not retrieve those items that are themselves an instance of film (Q11424).<br>The asterisk (<code>*<\/code>) after the path element means \u201czero or more of this element\u201d. Thus the matching pattern <br>?item <strong>wdt<\/strong>:<strong>P31<\/strong>\/<strong>wdt<\/strong>:<strong>P279<\/strong>* wd:Q11424<br>could match:<br>?item <strong>wdt<\/strong>:<strong>P31<\/strong>  wd:Q11424.  <br><em>or<\/em> <br>?item <strong>wdt<\/strong>:<strong>P31<\/strong>\/<strong>wdt<\/strong>:<strong>P279<\/strong>  wd:Q11424.  <br><em>or<\/em> <br>?item <strong>wdt<\/strong>:<strong>P31<\/strong>\/<strong>wdt<\/strong>:<strong>P279<\/strong>\/<strong>wdt<\/strong>:<strong>P279<\/strong>  wd:Q11424. <br><em>or<\/em> <br>?item <strong>wdt<\/strong>:<strong>P31<\/strong>\/<strong>wdt<\/strong>:<strong>P279<\/strong>\/<strong>wdt<\/strong>:<strong>P279<\/strong>\/<strong>wdt<\/strong>:<strong>P279<\/strong>  wd:Q11424.  <br>and so on.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Property paths The query construction that allows us to select items that belong to the same class makes use of property paths. Property paths are shorthand for writing down a path of properties between two items.&nbsp; To understand how this construction works, take a look at the graphic view of some information about the item [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":""},"categories":[13],"tags":[],"_links":{"self":[{"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/posts\/588"}],"collection":[{"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/comments?post=588"}],"version-history":[{"count":39,"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/posts\/588\/revisions"}],"predecessor-version":[{"id":1643,"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/posts\/588\/revisions\/1643"}],"wp:attachment":[{"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/media?parent=588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/categories?post=588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wdqs-tutorial.toolforge.org\/index.php\/wp-json\/wp\/v2\/tags?post=588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}