Anonymous

Item talk:Q50862: Difference between revisions

From geokb
no edit summary
No edit summary
Line 69: Line 69:
}
}
GROUP BY ?item ?itemLabel ?item_alt_label ?instance_ofLabel
GROUP BY ?item ?itemLabel ?item_alt_label ?instance_ofLabel
</sparql>
== Organizational Hierarchy ==
In the GeoKB, we use the inverse properties [[Property:P189|has subsidiary]] and [[Property:P190|is subsidiary of]] to describe the relationships between organizational entities like those in the USGS that are organized into a hierarchy. These can be used with SPARQL to construct a graph.
<sparql tryit="1">
PREFIX wd: <https://geokb.wikibase.cloud/entity/>
PREFIX wdt: <https://geokb.wikibase.cloud/prop/direct/>
SELECT ?item ?itemLabel ?hasSubsidiary ?isSubsidiaryOf
WHERE {
  ?org_types wdt:P2 wd:Q50862 . # Gets subclasses of USGS organization
  ?item wdt:P1 ?org_types . # Gets items in those classes
  OPTIONAL {
    ?item wdt:P189 ?hasSubsidiary . # get has subsidiary relationships
  }
  OPTIONAL {
    ?item wdt:P190 ?isSubsidiaryOf . # get is subsidiary of relationships
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}
</sparql>
</sparql>