Implement RDB2RDF direct mapping #74

Closed
cygri opened this Issue Aug 16, 2011 · 4 comments

Comments

Projects
None yet
3 participants
@cygri
Member

cygri commented Aug 16, 2011

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 Mar 7, 2012

Closed

Implement R2RML #84

@cygri

This comment has been minimized.

Show comment
Hide comment
@cygri

cygri Mar 21, 2012

Member

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

Member

cygri commented Mar 21, 2012

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

@cygri

This comment has been minimized.

Show comment
Hide comment
@cygri

cygri Mar 28, 2012

Member

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

Member

cygri commented Mar 28, 2012

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

@cygri

This comment has been minimized.

Show comment
Hide comment
@cygri

cygri Jun 11, 2012

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

Member

cygri commented Jun 11, 2012

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 Jun 11, 2012

@DidierDCH

This comment has been minimized.

Show comment
Hide comment
@DidierDCH

DidierDCH Jul 18, 2012

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 <BROL/SPORT>;
.
map:BROL_SPORT_ID a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:BROL_SPORT;
d2rq:property <BROL/SPORT#ID>;
d2rq:column "BROL.SPORT.ID";
d2rq:datatype xsd:decimal;
.
map:BROL_SPORT_NAME a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:BROL_SPORT;
d2rq:property <BROL/SPORT#NAME>;
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

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 <BROL/SPORT>;
.
map:BROL_SPORT_ID a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:BROL_SPORT;
d2rq:property <BROL/SPORT#ID>;
d2rq:column "BROL.SPORT.ID";
d2rq:datatype xsd:decimal;
.
map:BROL_SPORT_NAME a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:BROL_SPORT;
d2rq:property <BROL/SPORT#NAME>;
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