0

I want to write a SPARQL query which returns all relationship(s) between The Netherlands and Amsterdam, using DBPedia, but not knowing that "Amsterdam" could be the capital city and not knowing that "Netherlands" is in fact a country. I just want to know how they are connected, in any way possible.

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
Madelyn
  • 1
  • 1
  • 2
    If you are already learning SPARQL, then you should be able to write a query that returns everything for a given subject URI, right? And you know that you can also give an URI for the object of the triple pattern, correct? That's all you have to do, just put the DBpedia URI for Netherlands into the subject position, the URI for Amsterdam into the object position. – UninformedUser Sep 18 '16 at 17:44
  • 1
    In a next step, you might recognize that this only returns the relations from Netherlands to Amsterdam, but in DBpedia some relations might exist from Amsterdam to Netherlands, thus, instead of your initial triple pattern `:Netherlands ?p :Amsterdam .` you use the reversed one, i.e. `:Amsterdam ?p :Netherlands .` – UninformedUser Sep 18 '16 at 17:47
  • 1
    The last step would be to put both into a single SPARQL query, which can be done by using the UNION operator: https://www.w3.org/TR/sparql11-query/#alternatives – UninformedUser Sep 18 '16 at 17:48
  • Check this out http://stackoverflow.com/questions/35408237/sparql-which-is-the-path-connecting-two-objects – Ivo Velitchkov Sep 19 '16 at 16:15

1 Answers1

0

Try this:

SELECT ?verb1 ?verb2 WHERE {
  wd:Q55 ?verb1 wd:Q727.
  wd:Q727 ?verb2 wd:Q55  
}

on Wikidata Query Service

Alexan
  • 8,165
  • 14
  • 74
  • 101