Skip to content

Loading…

Implement RDB2RDF direct mapping #74

Closed
cygri opened this Issue · 4 comments
@cygri
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
Closed

Implement R2RML #84

@cygri
D2RQ member

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

@cygri
D2RQ member

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

@luiseufrasio luiseufrasio was assigned
@cygri
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
@DidierDCH

Testing with one w3c test case:

Creating the test data:

CREATE TABLE Sport (
ID integer,
Name varchar2 (50),
PRIMARY KEY (ID)
);

CREATE TABLE Student (
ID integer,
Name varchar2(50),
Sport integer,
PRIMARY KEY (ID),
FOREIGN KEY(Sport) REFERENCES Sport(ID)
);

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);

commit;

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.:

Table BROL.SPORT

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"^^http://www.w3.org/2001/XMLSchema#decimal .
file:///C:/d2rq-0.8.1/prez_dump_d2rq.ttl#BROL/STUDENT/10 http://www.w3.org/2000/01/rdf-schema#label "STUDENT #10" .
file:///C:/d2rq-0.8.1/prez_dump_d2rq.ttl#BROL/STUDENT/10 http://www.w3.org/1999/02/22-rdf-syntax-ns#type

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.