-1

I want to write a SPARQL query to retrieve all properties and values for an instance in a particular domain. For example, I want all properties and values of the singer "Sting" only in "MusicalArtist" domain. How can I do this?

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • This is not a forum; it's a question and answer site for specific programming problems. This is a pretty basic question, too, and one that's probably answered in the SPARQL specification. That said, did you see this question, [Select a property value from dbpedia resource with SPARQL](http://stackoverflow.com/q/22667987/1281433), whose author begins with "I can retrieve all information about a resource with this query: …"? – Joshua Taylor May 22 '14 at 14:52
  • What do you mean that you 'want all properties and values of the singer "Sting" only in "MusicalArtist" domain'? I understand what it would be get all the properties/values for a resource (e.g., the singer Sting), but I don't know what you mean by "properties and values … only in [some particular] domain". – Joshua Taylor May 22 '14 at 15:11
  • @Joshua Taylor Thank you for your answer and i'm sorry for the mistake about "forum". The question that you have indicated is a mine question. (Select a property value from dbpedia resource with SPARQL) So the problem is: if use the Sparql query in the other post (that you have indicated) PREFIX db: PREFIX prop: PREFIX onto: SELECT ?property ?value WHERE { db:Barry_White ?property ?value }; – user3465271 May 22 '14 at 15:45
  • i have all properties and values about Barry_White. Now in DBpedia we have a hierachy of class: for example Work, with children MusicalWork, Album, Single. Now i want to retrieve the same informations of the specified query, but not in all DBpedia knowledge base. I want to know all properties of MusicalWork, and then the value for this properties for the instance "Barry White". – user3465271 May 22 '14 at 15:46
  • Do you mean that you the values (of properties of Barry_White) that are instances of the class MusicalWork? – Joshua Taylor May 22 '14 at 15:49
  • exactly. I need to write two query. One for retrieve all about MusicalWork and the second for the values (of properties of Barry_White) that are instances of the class MusicalWork. – user3465271 May 22 '14 at 16:10

1 Answers1

0

If I understand you correctly, this is a pretty basic SPARQL question, and you'd be better off starting with a good tutorial on SPARQL, or sitting down with the SPARQL 1.1 Query Language document. Just skim through it, you don't need to memorize everything right away, but just get familiar with it. After all, Stack Overflow isn't for reproducing standard documentation; you're expected to already be familiar with that.

As you've shown in a previous question, you can ask for all properties of a given subject with a query like:

select ?p ?o where {
  dbpedia:Barry_White ?p ?o
}

You can select all instances of a particular class, e.g., dbpedia-owl:MusicalWork with a query like

select ?o where {
  ?o a dbpedia-owl:MusicalWork
}

It sounds like you're simply asking how to combine the two. It's just

select ?p ?o where { 
  dbpedia:Barry_White ?p ?o .
  ?o a dbpedia-owl:MusicalWork
}

SPARQL results (0 results)

That query doesn't actually have any results, because Barry White isn't related to anything that's a MusicalWork, evidently. However, if you just ask for Works that he's associated with, you'll get a few results:

select ?p ?o where { 
  dbpedia:Barry_White ?p ?o .
  ?o a dbpedia-owl:Work
}

SPARQL results (3 results)

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • Thank you @Joshua Taylor, your answer is the answer that i want. I start to view the SPARQL Documentation an Tutorial, but i have some problems with the syntax, but i want to learn to fix it. Thank you so much. – user3465271 May 22 '14 at 16:49