This example is on Windows 10. But setting up on unix should be similar.
This also assumes that you have JAVA installed. As of this writing, Java 11 is the latest version.
Set Up a Tomcat Web Server
Google for Tomcat download. Download tomcat and unpack to a folder, e.g. C:\Programs (Downloads for me took about 1 minute total.)
Deploy the RDF4J Webapps in Tomcat
Google for RDF4J download. Download the ZIP file. Open the ZIP and find the war folder.
Copy rdf4j-server.war and rdf4j-workbench.war into tomcat's webapps folder.
Run Tomcat
Start tomcat using its bin folder's startup.bat script. (Wait till console shows Server startup in ... ms)
Start using your triple store!
In a browser, go to http://localhost:8080/rdf4j-workbench
Congratulations, you have a working triple store! (If you don't, reply/comment and tell me what you're seeing.)
Create a new repository
RDF4J lets you have multiple "repositories" which are basically independent triple stores within the RDF4J server. Let's set up one.
On the workbench user interface, click New Repository and create a repository, give it an id like test, a title like a test repo and click Next then Create.
Put in some data
On the workbench user interface, Click SPARQL Update Paste this in:
PREFIX : <http://example/>
INSERT DATA {
:Mark a :Person .
:Judi a :Person .
:Linda a :Person .
:Mark :knows :Judi .
:Judi :knows :Linda .
:Mark :knows :Linda .
}
Click Execute
You can also load data by uploading files.
Explore the data
- Click
Typesto see that it figured out that<http://example/Person>is a type. - Click on
<http://example/Person>to see the instances of this type. - Click on
<http://example/Judi>to all the triples with<http://example/Judi>as the subject or object.
Add namespaces to make things less verbose
- Click
Namespaces. - Enter
testin prefix box, andhttp://example/in Namespace box - Click
Update.
Now explore data again and see that it uses the test: namespace prefix rather than the full URI when showing data, e.g. test:Mark and test:knows.
SPARQL Query your data
Click Query Enter this:
select * where {?x a ?y} limit 10
Click Execute.
Beyond 5 minutes...
Want to query as a SPARQL Endpoint?
Use URL of form below, where test is the repository id you specified. The part after query= must be URL encoded. e.g.,
curl http://localhost:8080/rdf4j-server/repositories/test?query=select%20%2A%20%7B%3Fx%20a%20%3Fy%7D
Want to load your triple store over a REST API?
Use URL of form below to push statements.
curl --data @mydata.ttl -H "Content-Type: application/x-turtle" http://localhost:8080/rdf4j-server/repositories/test/statements
You can store to a named graph by adding a ?context parameter to the URL, e.g.,
curl -v --data @mydata.ttl -H "Content-Type: application/x-turtle" \
http://localhost:8080/rdf4j-server/repositories/test/statements?context=%3Chttp://graph1%3E
More realistic dataset
Try with more triples, and multiple named graphs.
Approach:
- Use LUBM data set (e.g. 1 University)
- Put ontology into 1 named graph, data for Univ in another.
- Query against joined graphs
RDF4J:
- Create repo named
lubm1 - For ontology:
- Click
Add - Put in RDF Data URL of http://swat.cse.lehigh.edu/onto/univ-bench.owl
- Select
Data formatofRDF/XML - Click
Upload - For data:
- make a zip of all the University*.owl files from LUBM 1 University data set
- click Add and choose the zip file you made
- set Base URI to http://www.University0.edu (which will make graph name <http://www.University0.edu>)
- Select
Data formatofRDF/XML - Click
Upload
Now you will have 2 graphs: 1 with TBox and 1 with University0 ABox data.
Inferred triples land in the default graph.





