This document is part of the D2RQ documentation.

Getting Started with D2RQ

This page gives a quick introduction to get you up and running with D2RQ.

Note: Vadim Eisenberg has written a more detailed step-by-step guide to setting up D2R Server with an example database.

Quick start

You need:

What to do:

  1. Download and extract the archive into a suitable location.

  2. Download a JDBC driver from your database vendor. Place the driver's JAR file into D2R Server's /lib directory. A list of JDBC drivers from different vendors is maintained by Sun. Also take note of the driver class name (e.g. org.postgresql.Driver for PostgreSQL or oracle.jdbc.driver.OracleDriver for Oracle) and JDBC URL pattern (e.g. jdbc:mysql://servername/database for MySQL) from the driver's documentation. Drivers for MySQL and PostgreSQL are already included with D2R Server.

  3. Generate a mapping file for your database schema using the generate-mapping tool. Change into the D2R Server directory and run:

    generate-mapping -o mapping.ttl -d
        -u db-user -p db-password jdbc:url:...

    mapping.ttl is the name for the new mapping file. -d can be skipped for MySQL.

  4. Start D2R Server:

    d2r-server mapping.ttl
  5. Test the Server: Open http://localhost:2020/ in a web browser.

    Screenshot of D2R Server's web interface

    You can browse the database content or use the SPARQL Explorer to execute queries and display results in a number of formats.

  6. Run a SPARQL query from the command line using the d2r-query tool:

    d2r-query mapping.ttl "SELECT * { ?s ?p ?o } LIMIT 10"
  7. Or load the query from a file, here called query.sparql:

    d2r-query mapping.ttl @query.sparql
  8. Generate an RDF dump using the dump-rdf tool:

    dump-rdf mapping.ttl -o dump.nt

Customizing the D2RQ mapping

After you're up and running, the next step is typically to refine the RDF output by customizing the D2RQ mapping.

The D2RQ Platform uses the D2RQ Mapping Language to map the content of a relational database to RDF. A D2RQ mapping specifies how resources are identified and which properties are used to describe the resources.

The generate-mapping script automatically generates a D2RQ mapping from the table structure of a database. The tool generates a new RDF vocabulary for each database, using table names as class names and column names as property names. Semantic Web client applications will understand more of your data if you customize the mapping and replace the auto-generated terms with terms from well-known and publicly accessible RDF vocabularies.

The mapping file can be edited with any text editor. Its syntax is described in the D2RQ language specification.

D2R Server will automatically detect changes to the mapping file and reload appropriately when you hit the browser's refresh button.

Note: The HTML and RDF browser interfaces only work for URI patterns that are relative and do not contain the hash (#) character. For example, a URI pattern such as entries/ is browsable, but is not. The mapping generator only creates browsable patterns. Non-browsable patterns still work in the SPARQL interface and in RDF dumps.