Skip to content


Implement RDB2RDF direct mapping #74

cygri opened this Issue · 4 comments
D2RQ member

Add a --w3c switch on generate-mapping that produces a mapping file compatible with W3C's Direct Mapping.

Here's a rough plan for implementing it:

  • Add another encoding form to URI patterns, in addition to urlencode and urlify: encode simply applies %-encoding as defined in the spec Done
  • Add a W3CMappingGenerator parallel to the existing MappingGenerator Done
  • Make sure that in this one, instance/property/class URIs are constructed as defined in the spec Done
  • Make sure that in this one, table and column names are properly encoded as defined under “percent-encode” in the spec Done
  • Implement the datatype mapping table from R2RML's “natural mapping” when assigning XSD types to the property bridges (see also related but more complex issue #113)
  • This requires base64 encoding for binary types as a new option that is currently not yet supported by D2RQ (#112)
  • The natural mapping requires careful testing to make sure we produce canonical lexical forms, especially for the primary key values that go into the subject URIs
  • The Direct Mapping requires that duplicate rows in a table without unique key produce two blank nodes. Find a way how to make that work in D2RQ, especially on databases other than Oracle (where ROWID makes this easy). (see also this issue in the W3C working group tracker where I try to argue that maybe this should be changed in the spec)
  • Make sure that we pass the test suite provided by W3C (#135)
  • This would all benefit from first introducing the mapping API (#28)
@cygri cygri referenced this issue

Implement R2RML #84

D2RQ member

Preliminary support for the Direct Mapping has been contributed by @luiseufrasio and for now lives in the direct-mapping branch: da50a6f

D2RQ member

@luiseufrasio's work has been merged into master: d84d66e

@luiseufrasio luiseufrasio was assigned
D2RQ member

Direct Mapping (in its non-duplicate-preserving flavour) is now available via --w3c switch. We pass all the tests except the duplicate-preservation tests, but still need to incorporate the tests into the standard D2RQ test suite (#135).

@cygri cygri closed this

Testing with one w3c test case:

Creating the test data:

ID integer,
Name varchar2 (50),

ID integer,
Name varchar2(50),
Sport integer,

INSERT INTO Sport (ID, Name) VALUES (100,'Tennis');
INSERT INTO Student (ID, Name, Sport) VALUES (10,'Venus Williams', 100);
INSERT INTO Student (ID, Name, Sport) VALUES (20,'Demi Moore', NULL);


Generating the mapping: (note: this is in the usual d2rq format, yet with the right definitions for the produced output to match the direct mapping standard)

generate-mapping -u uuu -p ppp -d oracle.jdbc.OracleDriver --schemas BROL -o .\configs\prez_dm.ttl --w3c --verbose jdbc:oracle:thin:@srv:1521:db

givs a.o.:


map:BROL_SPORT a d2rq:ClassMap;
d2rq:dataStorage map:database;
d2rq:uriPattern "BROL/SPORT/ID=@@BROL.SPORT.ID@@";
d2rq:class ;
map:BROL_SPORT_ID a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:BROL_SPORT;
d2rq:property ;
d2rq:column "BROL.SPORT.ID";
d2rq:datatype xsd:decimal;
map:BROL_SPORT_NAME a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:BROL_SPORT;
d2rq:property ;
d2rq:column "BROL.SPORT.NAME";

Obtaining the triples:
dump-rdf -o .\dumps\prez_dm_dump.ttl .\configs\prez_dm.ttl

gives a.o.:

file:///C:/d2rq-0.8.1/prez_dump_d2rq.ttl#BROL/STUDENT/10 file:///C:/d2rq-0.8.1/vocab/BROL_STUDENT_SPORT file:///C:/d2rq-0.8.1/prez_dump_d2rq.ttl#BROL/SPORT/100 .
file:///C:/d2rq-0.8.1/prez_dump_d2rq.ttl#BROL/STUDENT/10 file:///C:/d2rq-0.8.1/vocab/BROL_STUDENT_NAME "Venus Williams" .
file:///C:/d2rq-0.8.1/prez_dump_d2rq.ttl#BROL/STUDENT/10 file:///C:/d2rq-0.8.1/vocab/BROL_STUDENT_ID "10"^^ .
file:///C:/d2rq-0.8.1/prez_dump_d2rq.ttl#BROL/STUDENT/10 "STUDENT #10" .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.