Ordering and limiting triples

When building new RDF triples with CONSTRUCT, you can use the operators described in Step 2.10 (Ordering query results) in order to organise and delimit the variable bindings retrieved from the dataset.

The following query will build “creator” relationships only for the first 10 albums recorded by the Beatles, following alphabetical order of the titles, along with their tracks:

PREFIX dbpedia: <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX mo: <http://purl.org/ontology/mo/>

CONSTRUCT { ?album dc:creator dbpedia:The_Beatles .
            ?track dc:creator dbpedia:The_Beatles .
      }
WHERE { dbpedia:The_Beatles foaf:made ?album .
        ?album mo:record ?record .
        ?album dc:title ?album_title .
        ?record mo:track ?track . 
  }
ORDER BY ?album_title
LIMIT 10

Share this article:

This article is from the free online course:

Introduction to Linked Data and the Semantic Web

University of Southampton

Get a taste of this course

Find out what this course is like by previewing some of the course steps before you join: