following freebase MQL finds 5 artists and 50 albums for each artists.
[{
  "type" : "/music/artist",
  "name":null,
  "album" : [{
    "name" : null,
    "count":null,
    "limit":50
  }],
  "limit":5
}]
first try - without a subquery
I can write SPARQL like this:
SELECT ?artist ?album
WHERE
{
    ?artist :type :/music/artist .
    ?artist :album ?album
}
LIMIT n
but, I don't know how many n should be specified because SPARQL has no hierarchy as far as I know.
second try - with a sub-query (not sure this works correctly)
Following sub-query looks like working.
SELECT ?artist ?album
WHERE
{
    ?artist :album ?album .
    {
        SELECT ?artist
        WHERE
        {
            ?artist :type :/music/artist
        }
        LIMIT k
    }
}
LIMIT n
But I don't know how to specify k, n to get 50 albums foreach 5 artists.
Some data with endpoint
- SPARQL Endpoint : http://dbpedia.org/sparql
Could anyone write SPARQL which print 5 artists and their 5 painting for each artists?
Below query prints artists and their paints without LIMITing result.
PREFIX dbpedia-owl:<http://dbpedia.org/ontology/>
PREFIX prop:<http://dbpedia.org/property/>
SELECT ?painting ?artist
WHERE
{
    ?painting prop:artist ?artist .
    {
        SELECT ?artist
        {
            ?artist rdf:type dbpedia-owl:Artist.
        }
    }
}
Thanks.
 
     
     
    