0

I have a requirement to show all the classes and their respective instances when the user accesses our website. We use Allegrograph as our RDF database. So once the user selects the repository from which to fetch the data, we need to show all the classes and their respective instances present in the entire repository. SO is it possible to achieve this through a single SPARQL query?

I know the below SPARQL will fetch all the classes,

SELECT DISTINCT ?class
WHERE {
  ?s a ?class .
}

But how do i get all the instances for each class that the above SPARQL query returns? I need to know if it is possible in a single SPARQL query. Your help is much appreciated as it is crucial for our project.

RobV
  • 28,022
  • 11
  • 77
  • 119
sraf
  • 57
  • 7
  • Duplicated with alternative answers at http://answers.semanticweb.com/questions/25646/is-it-possible-to-get-all-classes-and-their-respective-instances-using-a-single-sparql-query - - please only post your question in one place and then have some patience, people answering your questions are all volunteers and cross-posting to multiple forums and/or lists only serves to annoy the people helping you while reducing the chance that someone with the same problem encountering your question in the future actually finds a useful answer – RobV Dec 13 '13 at 15:49

1 Answers1

2
SELECT ?s ?class WHERE  { ?s a ?class }
AndyS
  • 16,345
  • 17
  • 21