Practical Exercises for A Two Day Introduction to the Web of Data
These exercises accompany the training material found here.
Practical exercises are an essential aspect of learning any new technology. This page provides some introductory level practical exercises that will take you through the six main steps in creating and publishing linked data:
- Modelling Data using RDF
- Writing RDF using Turtle, and choosing URIs for things
- Creating an RDF Schema
- Converting Data into RDF
- Publishing RDF Data into a Triple Store
- Querying Data using SPARQL
These exercises are all based on space flight data published by the NASA Space Science Data Center as part of their Master Catalog.
A word about text editors
Most of these exercises will require a text editor. You may have Notepad on your Windows machine, but you may find that an editor that supports syntax highlighting will allow you to see where you have gone wrong more easily (though of course we know you will get it right first time!).
You might find an online editor that understands turtle/n3 to be of use: http://buzzword.org.uk/2010/n3edit/
A couple of free text editors in no particular order:
You may also find it useful to dump your sparql queries and answers to a text file so that you have a record of your progress, as an aid memoir.
Exercise 1: Modelling Data using RDF
In this exercise you will model some space flight data using the core RDF model.
Assignment
Draw an RDF graph showing the resources being described in the following web pages:
Suggested Approach
- Identify the key things being discussed
- Consider what information would be needed to generate these pages
- Consider how the things described relate to each other
- Consider people, places, events, concepts
- Consider how to handle the Disciplines show on the pages
- If you have time, see what other information you can find online about the things described and consider how that could be added to your model
Exercise 2: Writing RDF using Turtle, and choosing URIs for things
In this exercise you will learn to write your model down in a machine-readable format called Turtle.
Assignment
Take the RDF graph you drew in Exercise 1 and write the statements down using Turtle.
Suggested Approach
- A basic text editor is fine for this task, use any text editor you're comfortable with
- Consider the things you have in your graph and the URI patterns you will need
- Make sure you create a description for each resource in your diagram that has properties
- Count up the arrows in your graph, you should have the same number of statements in your Turtle
- Validate your turtle using Joshua Tauberer's RDF Validator
- If you have time, take a look at Dave Beckett's command line tool, rapper
Exercise 3: Describing your data with RDF Schema
In this exercise you will create an RDF Schema to describe your space model.
Assignment
Starting with the model you created in Exercises 1 and 2, write an RDF Schema to describe the properties and classes you are defining.
Suggested Approach
- Identify the properties you have used in your model.
- Consider if they are specific to your space data, or more general and possibly already described.
- Identify the classes you have used in your model.
- Consider if they are specific to your space data, or more general and possibly already described.
- Write an RDF description of each property and class, making you have added at least a label and description.
- Consider if any of your properties are specific enough to warrant a domain or range adding.
- Consider if any of your properties or classes are more specialised versions of existing ones.
- If you have time, search for some of the common schema we discussed and see how they are written.
Exercise 4: Linking to existing data
The purpose of this exercise is to understand how to link your data to the web of data.
Assignment
Using the model you created in Exercises 1, 2 and 3, take your sample data set and:
- Use URIs that will dereference
- Use Common vocabularies where possible foaf: dc: rdfs: owl: (Make sure your vocabulary terms all dereference.)
- Link objects of interest in your data to other datasets - some questions to help you:
- What datasets can you find Cape Canaveral in?
- How many URIs can you find for NASA?
- Can you link any three of Films, Music, Books, TV or News Items to your data? What properties will you use?
- Create a URI for yourself, and use FOAF to write some triples. Can you connect yourself indirectly to the Apollo 11 spacecraft?
- Consider what a license to use your data might need to allow
- Describe your dataset using http://lab.linkeddata.deri.ie/ve2/ (but donÍt hit the announce button!)
Suggested Approach
Exercise 5: Publishing RDF Data using a Triple Store
In this exercise you will publish the data from Exercise 4 into a triple store.
Assignment
Using the data you converted in Exercise 4, publish this data into the training-exercises store on the Talis Platform.
Suggested Approach
- Check you have a suitable tool installed. We suggest curl.
- Ensure you have the correct content-type.
- Once you've uploaded, test some of the URIs in your data using curl and a web browser.
Sample upload command:
curl --digest -u USER:PASS -H content-type:application/rdf+xml -d @file.rdf.xml http://api.talis.com/stores/training-exercises/meta
Exercise 6: Querying the Data
In this exercise you will write queries against an example model built from the NASA data. You can browse through the data at the space linked data incubator.
Assignment
Use this basic SPARQL editor to execute queries that answer these questions:
- What properties are in use in the space data?
- What classes are in use in the space data?
- Are there are any resources that have an rdf:type of http://purl.org/net/schemas/space/Discipline?
- Which resources have an rdf:type of http://purl.org/net/schemas/space/Discipline?
- DESCRIBE one of the resources that you found in the previous question
- What are the labels of the Disciplines?
- What are the URIs, international designators and names of all spacecraft associated with the "Planetary Science" discipline?
- What are the names and masses of all of the spacecraft associated with the launch http://nasa.dataincubator.org/launch/1969-059?
- What are the names of all the launch vehicles?
- Which space agencies have launched Spacecraft in the "Human Crew" discipline?
- What was the mass of the heaviest spacecraft launched in the "Human Crew" discipline?
- What was the mass of the lightest spacecraft launched in the "Human Crew" discipline?