d2rq / d2rq

Database to RDF mapping engine and SPARQL server
http://d2rq.org/
311 stars 114 forks source link

Implement RDB2RDF direct mapping #74

Closed cygri closed 12 years ago

cygri commented 13 years ago

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:

cygri commented 12 years ago

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

cygri commented 12 years ago

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

cygri commented 12 years ago

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

DidierDCH commented 12 years ago

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