Want to keep learning?

This content is taken from the University of Southampton's online course, Introduction to Linked Data and the Semantic Web. Join the course to learn more.

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

This work is a derivative of ‘Using Linked Data Effectively’ by The Open University (2014) and licensed under CC by 4.0 International Licence adapted and used by the University of Southampton. http://www.euclid-project.eu/

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: