1

I have this wikidata query, that tries to find all the companies owned directly or indirectly by the Walt Disney company.

SELECT ?company ?companyLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?company (wdt:P127|wdt:P749)* wd:Q7414.
  ?company wdt:P31/wdt:P279* wd:Q4830453.
}

I'm trying to find if company is owned by Disney (P127) or where Disney is the parent organization (P749).

Property P749 is a subproperty of P127. There may be other subproperties of "owned by" that I don't know about.

Can I make a query that returns all companies that has relation that has any subproperty of "owned by" in relation to Disney? I also need to return the subsidiaries of the direct subsidiaries, and the subsidiaries of those subsidiaries and so on.

logi-kal
  • 7,107
  • 6
  • 31
  • 43
fgregg
  • 3,173
  • 30
  • 37
  • 1
    Not possible. And even the [ALP service](https://wiki.blazegraph.com/wiki/index.php/PropertyPaths) doesn't support complex conditions like `?edge ^wikibase:directClaim/wd:P1647* wd:P127`. However, `wd:P127` has only three (direct and indirect) subproperties, i.e. you can write something like `(wdt:P127|wdt:P749|wdt:P3931)`. – Stanislav Kralin Jun 27 '18 at 07:28
  • I think this is the answer, as I basically have the same question as https://stackoverflow.com/questions/26698675/sparql-property-path-queries-with-arbitrary-properties. If you'd like to give this as the answer, I'll accept it. – fgregg Jun 27 '18 at 14:44

1 Answers1

1

You can do this by means of a recursive property path:

?company ?p wd:Q7414.
?p rdfs:subPropertyOf* P:127 .
Jeen Broekstra
  • 21,642
  • 4
  • 51
  • 73
  • This responds to my question as I originally asked it. Unfortunately, I need to also get the subsidiaries of the the subsidiaries, and the subsidiaries of those subsidiaries and so on. – fgregg Jun 27 '18 at 00:52
  • @fgregg then, what prevents you from querying also for the wdt:P355 property of your companies? – UninformedUser Jun 27 '18 at 03:12
  • I mean subsidiaries informally here. Orgs that are descendant of other orgs throught an owned_by relation or a subclass of the owned_by relations. – fgregg Jun 27 '18 at 03:19
  • @fgregg I'm not overly familiar with the Wikidata ontology. You'll have to edit your question to give more specific examples (the properties involved, the expected results, and so on). – Jeen Broekstra Jun 27 '18 at 03:26
  • 1
    @fgregg I don't get it. What's wrong with `?p rdfs:subPropertyOf* P:127 .` Which in fact returns all subproperties of `owned_by` relation which you then can use as predicate in the triple pattern? – UninformedUser Jun 27 '18 at 08:54
  • that part of the query is fine, but then `?company ?p* wd:q7414` does not work. `?company ?p wd:q7414` works, but that only gets me the companies directly owned or controlled, not the companies that are owned or controlled by a company that Disney owns or controls. – fgregg Jun 27 '18 at 14:42