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.

Exercise: try out RDF!

Here you have a chance to write some RDF and check your understanding of how to express statements in this way.

It is important to try writing and editing some RDF to ensure you can apply the concepts that we’ve covered so far to a slightly different example


Study the following RDF statements, expressed in the Turtle syntax, then attempt the exercise that follows. Note: We don’t expect you to do this off the top of your head. Revisit the example RDF snippets that we’ve seen in the course so far, and then apply the syntax and structure rules that they use to this example.

@base <http://www.euclid-project.eu/examples/> . 
@prefix vocab: <http://www.euclid-project.eu/ns#> . 
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . 
@prefix foaf: <http://xmlns.com/foaf/0.1/> . 

vocab:ResearchProject rdfs:subClassOf foaf:Group . 

vocab:consortiumMember rdfs:subPropertyOf foaf:member . 

<barry>    a foaf:Person ; 
           foaf:givenName "Barry" ; 
           foaf:familyName "Norton" . 

<euclid> rdfs:label "The Euclid Project"@en, "Das Projekt Euclid"@de ; 
           vocab:consortiumMember <barry> . 

We have developed an interactive exercise for you to use to try out RDF and check out your understanding. We suggest that you open this exercise in a new browser window or tab so that you can view it alongside the instructions.

It is also strongly recommended that you revisit Step 1.9 and Step 1.10 and you read and / or print out the attached Exercise 1 worksheet & FAQs before you have a go at answering the following questions. You may find it useful to watch the video screencast walkthrough of how to approach this activity.

  1. Re-express the statements in NTriples (i.e. remove all prefixes and abbreviations to give full triples in absolute URIs - you should look at the example in Step 1.9 for guidance on how to approach this).
  2. Add a resource representing yourself, attaching your name using the FOAF properties. (Look at how it has been done for Barry.)
  3. Check that you have correctly added yourself by executing the following SPARQL query: SELECT ?person WHERE { ?person a foaf:Person . } You should see two results: Barry and you (note: you will need to use the interactive exercise to execute the query and examine the results - further instructions below).
  4. In the query from (3.), replace the property foaf:Person for foaf:Agent. Can you tell why the result is the same as before?

Instructions on using the interactive exercise for questions 3. and 4.

For question 3. you should use interactive exercise to execute the query and examine the results.

The interactive exercise will let you enter RDF as either Turtle or NTriples. You can then run SPARQL queries on this input and receive the results, which means you can try out the RDF concepts that we’ve covered in the course.

When you load the link for the exercise, the RDF statements (in Turtle) will be displayed automatically in the “RDF input” box. To execute a SPARQL query (for Question 3.), you need to use the lower half of the form.

Note: This exercise will work on mobile devices, but typing the code will be much less prone to errors using a keyboard, and a larger screen will make it easier to manage your code. We recommend using a PC or laptop if possible.

You may wish to post your answers in the comments to discuss them with your fellow learners particularly if you are stuck and would like to seek help from fellow learners. We have provided some model answers which are available in PDF format from the bottom of this page but your learning will be enhanced if you don’t look at them until you have at least attempted the questions and sought help.

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: