Template:SPARQLWorkshopQuery

From Wikibase Personal data
Jump to navigation Jump to search
  1. defaultView:Graph

SELECT ?rel ?pred ?obj ?item ?domain ?domainLabel ?range ?rangeLabel

  WITH {
    SELECT ?table 
    WHERE {
      pdio:{{{workshop}}} pdiot:P63 ?table.
    }
  } AS %workshop
  WHERE
  {
    
  OPTIONAL {
    ?table pdiop:P26 ?domain_prop.
    ?domain_prop pdiops:P26 ?domain.
    ?domain_prop pdiopq:P27 ?domainLabel
  }.
  OPTIONAL {
    ?table pdiop:P26 ?range_prop.
    ?range_prop pdiops:P26 ?range.
    ?range_prop pdiopq:P27 ?rangeLabel
  }.
  {
    SELECT ?domain ?range WHERE {
         INCLUDE %workshop.
         ?table pdiop:P25 ?relationshipStatement.
         ?relationshipStatement pdiopq:P24 ?domain.
         ?relationshipStatement pdiopq:P23 ?range.
      }
    
  }
  UNION
  {  
    SELECT ?domain ?range WHERE {
         INCLUDE %workshop.
         ?table pdiop:P58 ?relationshipInStatement.
         ?relationshipInStatement pdiops:P58 ?range.
         ?relationshipInStatement pdiopq:P61 ?domain.
      }
  }
  UNION
  {  
    SELECT ?domain ?range WHERE {
         INCLUDE %workshop.
         ?table pdiop:P59 ?relationshipOutStatement.
         ?relationshipOutStatement pdiops:P59 ?domain.
         ?relationshipOutStatement pdiopq:P60 ?range.
      }
  }.

}