-1

How to write SPARQL query to return all concepts related to Afghanistan from DBpedia?

SPARQL is new for me.

6
  • What do you mean by "concepts"? The classes shown (dbpedia.org/page/Afghanistan)[here] in the rdf:type section? Nov 25, 2017 at 9:20
  • concept mean All information related to Afghanistan. i need a SPARQL query to get all related things to Afghanistan from DBPedia.
    – RafiO
    Nov 25, 2017 at 9:23
  • To be honest, you should start with a SPARQL tutorial then. I mean, this is quite a simple query. for outgoing information, i.e. information about Afganistan, use: SELECT * {<http://dbpedia.org/resource/Afghanistan ?p ?o } For incoming, reverse the triple. For both, use UNION Nov 25, 2017 at 9:40
  • thank you, actually i do not know sparql, but this is part of my assignment, i tried to learn but to be honest it is not easy for beginners.
    – RafiO
    Nov 25, 2017 at 9:42
  • What kind of assignment is it? What is the overall task? SPARQL isn't that difficult. RDF is made of triples resulting in some kind of graph, SPARQL tries to matches those triple resp. parts of the graph, thus, queries contain triple patterns Nov 25, 2017 at 9:56

1 Answer 1

1

The following query made to DBpedia results in showing complete data related to Afghanistan as a resource which could either be subject or object.

PREFIX dbr:<http://dbpedia.org/resource/>

SELECT ?subject ?predicate ?object

WHERE {

{dbr:Afghanistan ?predicate ?object.} UNION 
{?subject ?predicate dbr:Afghanistan.}


}

P.S. Learning SPARQL book might be interesting!

Learning SPARQL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.