-2

I wonder using SparQL to express "How is India related to “Indira Gandhi”? (no need to find all existing relationships, but find at least an interesting one)?" under http://dbpedia.org/sparql to explore DBPedia(the RDF-ized version of Wikipedia)

An example query I have:

SELECT ?relationship 
WHERE { ?s rdf:type dbo:Country . 
        ?s rdfs:label "India"@en . 
        ?x a dbo:Person . 
        ?x rdfs:label "Indira Gandhi"@en . 
        ?x ?p ?s . 
        ?p rdfs:label ?relationship . 
        filter lang(?relationship = "en") 
}

Is there a better way to solve this?

Jeen Broekstra
  • 21,642
  • 4
  • 51
  • 73
Ze Li
  • 11
  • 2
  • What? What's the question here? Does it even have anything to do with programming? – Carcigenicate Nov 30 '16 at 20:50
  • Please search for "find all paths between two nodes with SPARQL" - this has been asked several times before. And please provide a starting SPARQL query. It doesn't make sense to show you the query if you don't know anything about SPARQL. – UninformedUser Nov 30 '16 at 21:25
  • Possible duplicate of [SPARQL: is there any path between two nodes?](http://stackoverflow.com/questions/30916040/sparql-is-there-any-path-between-two-nodes) – Jeen Broekstra Nov 30 '16 at 23:17
  • Upon rereading I think it's not quite a duplicate. It's still very unclear what you're after though. What is an 'interesting' relationship? Show what you've tried sofar and where exactly you're stuck. [edit] your question to add more details. Also have a look at [ask]. – Jeen Broekstra Dec 05 '16 at 20:48

1 Answers1

0

A quick solution (direct relationship) you can use this:

SELECT ?relation
WHERE 
{
    dbr:Indira_Gandhi ?relation dbr:India.
}

To find another indirect relationship between two nodes, read about finding paths between nodes.

M.Sarmini
  • 70
  • 3