Bladeren bron

Added an example and updated the README

Christophe Debruyne 8 jaren geleden
bovenliggende
commit
52eddd1790
5 gewijzigde bestanden met toevoegingen van 197 en 10 verwijderingen
  1. 31 10
      README.md
  2. 6 0
      example/config.properties
  3. 16 0
      example/mapping.ttl
  4. 141 0
      example/mysql.sql
  5. 3 0
      example/output.ttl

+ 31 - 10
README.md

@@ -17,16 +17,37 @@ $ java -jar r2rml-0.0.1-SNAPSHOT.jar config.properties
 
 Where `config.properties` is a properties file containing:
 
-- connectionURL, a JDBC connection URL to a database (required)
-- user, username for the user connecting to the database
-- password, password for the user connecting to the database
-- mappingFile, the R2RML mapping file (required)
-- outputFile, the output file (required)
-- format, format of the output files (default "TURTLE")
-- filePerGraph, flag to write the different graphs in separate files (default "false")
-- baseIRI, used in resolving relative IRIs produced by the R2RML mapping
-
-When named graphs are used in the R2RML mapping, one should use serelizations that support graphs such as N-QUADS and TRIG. The use of other serializations formats (such as TURTLE) results in all triples of all graphs being written away to that file. When setting the flag `filePerGraph` to `true` for seralization formats that do not support graphs, however, the value for `outputFile` will be used to create a directory in which a file will be created for each graph in RDF dataset.
+- `connectionURL`, a JDBC connection URL to a database (required)
+- `user`, username for the user connecting to the database
+- `password`, password for the user connecting to the database
+- `mappingFile`, the R2RML mapping file (required)
+- `outputFile`, the output file (required)
+- `format`, format of the output files (default "TURTLE")
+- `filePerGraph`, flag to write the different graphs in separate files (default "false")
+- `baseIRI`, used in resolving relative IRIs produced by the R2RML mapping
+
+When named graphs are used in the R2RML mapping, one should use serialization that support graphs such as N-QUADS and TRIG. The use of other serializations formats (such as TURTLE) results in all triples of all graphs being written away to that file. When setting the flag `filePerGraph` to `true` for serialization formats that do not support graphs, however, the value for `outputFile` will be used to create a directory in which a file will be created for each graph in RDF dataset.
+
+## Example
+
+The directory `example` contains an example of a mapping and configuration file. The example assumes the MySQL database to be called `r2rml`, be running on `localhost` and accessible to the user `foo` with password `bar`. The configuration file looks as follows:
+
+```
+connectionURL = jdbc:mysql://localhost/r2rml
+user = foo
+password = bar
+mappingFile = mapping.ttl
+outputFile = output.ttl
+format = TURTLE
+```   
+
+The output, after passing the properties file as an argument to the R2RML processor, should look as follows:
+
+```
+<http://data.example.com/employee/7369>
+        a                             <http://example.com/ns#Employee> ;
+        <http://example.com/ns#name>  "SMITH" .
+```
 
 ## License
 This implementation of R2RML is written by [Christophe Debruyne](http://www.christophedebruyne.be/). 

+ 6 - 0
example/config.properties

@@ -0,0 +1,6 @@
+connectionURL = jdbc:mysql://localhost/r2rml
+user = foo
+password = bar
+mappingFile = mapping.ttl
+outputFile = output.ttl
+format = TURTLE

+ 16 - 0
example/mapping.ttl

@@ -0,0 +1,16 @@
+@prefix rr: <http://www.w3.org/ns/r2rml#> .
+@prefix ex: <http://example.com/ns#> .
+
+<#TriplesMap1>
+    rr:logicalTable [ rr:tableName "EMP" ];
+    rr:subjectMap [
+        rr:template "http://data.example.com/employee/{EMPNO}";
+        rr:class ex:Employee;
+    ];
+    rr:predicateObjectMap [
+        rr:predicate ex:name;
+        rr:objectMap [ rr:column "ENAME" ];
+    ].
+	
+<#a> rr:objectMap <#b> .
+<#b> rr:column "ENAME" .

+ 141 - 0
example/mysql.sql

@@ -0,0 +1,141 @@
+-- phpMyAdmin SQL Dump
+-- version 4.2.10
+-- http://www.phpmyadmin.net
+--
+-- Host: localhost:3306
+-- Generation Time: May 10, 2016 at 08:47 PM
+-- Server version: 5.5.38
+-- PHP Version: 5.6.2
+
+SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
+SET time_zone = "+00:00";
+
+--
+-- Database: `r2rml`
+--
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `DEPT`
+--
+
+CREATE TABLE `DEPT` (
+  `DEPTNO` int(11) NOT NULL,
+  `DNAME` varchar(30) DEFAULT NULL,
+  `LOC` varchar(30) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `DEPT`
+--
+
+INSERT INTO `DEPT` (`DEPTNO`, `DNAME`, `LOC`) VALUES
+(10, 'APPSERVER', 'NEW YORK');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `DEPT2`
+--
+
+CREATE TABLE `DEPT2` (
+  `DEPTNO` int(11) DEFAULT NULL,
+  `DNAME` varchar(30) DEFAULT NULL,
+  `LOC` varchar(30) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `DEPT2`
+--
+
+INSERT INTO `DEPT2` (`DEPTNO`, `DNAME`, `LOC`) VALUES
+(10, 'APPSERVER', 'NEW YORK'),
+(20, 'RESEARCH', 'BOSTON');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `EMP`
+--
+
+CREATE TABLE `EMP` (
+  `EMPNO` int(11) NOT NULL,
+  `ENAME` varchar(100) DEFAULT NULL,
+  `JOB` varchar(20) DEFAULT NULL,
+  `DEPTNO` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `EMP`
+--
+
+INSERT INTO `EMP` (`EMPNO`, `ENAME`, `JOB`, `DEPTNO`) VALUES
+(7369, 'SMITH', 'CLERK', 10);
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `EMP2`
+--
+
+CREATE TABLE `EMP2` (
+  `EMPNO` int(11) DEFAULT NULL,
+  `ENAME` varchar(100) DEFAULT NULL,
+  `JOB` varchar(20) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `EMP2`
+--
+
+INSERT INTO `EMP2` (`EMPNO`, `ENAME`, `JOB`) VALUES
+(7369, 'SMITH', 'CLERK'),
+(7369, 'SMITH', 'NIGHTGUARD'),
+(7400, 'JONES', 'ENGINEER');
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `EMP2DEPT`
+--
+
+CREATE TABLE `EMP2DEPT` (
+  `EMPNO` int(11) DEFAULT NULL,
+  `DEPTNO` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `EMP2DEPT`
+--
+
+INSERT INTO `EMP2DEPT` (`EMPNO`, `DEPTNO`) VALUES
+(7369, 10),
+(7369, 20),
+(7400, 10);
+
+--
+-- Indexes for dumped tables
+--
+
+--
+-- Indexes for table `DEPT`
+--
+ALTER TABLE `DEPT`
+ ADD PRIMARY KEY (`DEPTNO`);
+
+--
+-- Indexes for table `EMP`
+--
+ALTER TABLE `EMP`
+ ADD PRIMARY KEY (`EMPNO`), ADD KEY `DEPTNO` (`DEPTNO`);
+
+--
+-- Constraints for dumped tables
+--
+
+--
+-- Constraints for table `EMP`
+--
+ALTER TABLE `EMP`
+ADD CONSTRAINT `emp_ibfk_1` FOREIGN KEY (`DEPTNO`) REFERENCES `DEPT` (`DEPTNO`);

+ 3 - 0
example/output.ttl

@@ -0,0 +1,3 @@
+<http://data.example.com/employee/7369>
+        a                             <http://example.com/ns#Employee> ;
+        <http://example.com/ns#name>  "SMITH" .