← every query · class 09 · queries/paths.rq

The components of product 17, at any depth (hasPart+)

The same answer in both regimes: this query asks only for what was written.

?component
component:blue-switch
component:spring
component:usb-c-cable

The query

# Property paths: arbitrary depth without recursion
# (slide "Aggregation and paths"). In SQL this would require a recursive CTE.
PREFIX onto:    <https://data.csoares.me/onto#>
PREFIX product: <https://data.csoares.me/product/>

SELECT ?component
WHERE {
  # "+" = one or more hops of onto:hasPart ("*" would also allow zero hops,
  # returning product:17 itself)
  product:17 onto:hasPart+ ?component .
}
ORDER BY ?component

Edit it in the query box →