D2R Server tutorial

Author: Vadim Eisenberg

The following tutorial describes how to use the example database and mapping that appear in the The D2RQ Mapping Language .
  1. Download and uncompress D2R Server
  2. Download a dump of an example database (with some entries from the ISWC 2002 conference): http://d2rq.org/example/iswc-mysql.sql
  3. Create a database "iswc" in MySQL
  4. Feed the downloaded iswc-mysql.sql into mysql by running (you should specify the full path of the downladed iswc-mysql.sql if you run mysql in another directory):
    $ mysql -u [username] -p[password] < iswc-mysql.sql
  5. Check that the database was created OK. In MySql run, for example:
    show tables;
    and
    select FirstName, LastName, email from persons;
  6. Download the example mapping file mapping-iswc.ttl
  7. Change the username in the downloaded mapping file to be your mysql username and add a password of your mysql (if the password is required for your mysql)

  8. Run d2r-server in the directory you uncompressed it in the step 1 (you should specify the full path of the mapping-iswc.ttl if you run mysql in another directory):
    d2r-server -p 8080 mapping-iswc.ttl
  9. Open the following URL with your web browser: http://localhost:8080/snorql/

  10. Run an example SPARQL query. Write the query into the text of the SPARQL section and push the "Go!" button. You will see the results of the query in the SPARQL results section. The following query returns the names and the email addresses of all the people in the database. You can see that the results match the SQL query select FirstName, LastName, email from persons; that you ran in mysql
    SELECT DISTINCT ?name ?email WHERE {
      ?person rdf:type foaf:Person.
      ?person foaf:name ?name ;
              foaf:mbox ?email
    }
    
  11. Examples of additional SPARQL queries
  12. And what if you want to update the data in the mapped database ? You can use SPARQL/Update and D2RQ/Update and D2R/Update Server prototype extensions. See the tutorial about D2RQ/Update and D2R/Update Server.