rdb2rdf mapping with d2rq and d2r server
play

RDB2RDF mapping with D2RQ and D2R Server Richard Cyganiak - PowerPoint PPT Presentation

RDB2RDF mapping with D2RQ and D2R Server Richard Cyganiak Presentation to W3C RDB2RDF WG, 10 Nov 2009 Topics 1. The D2RQ project 2. The D2RQ mapping language 3. Requirements for RDB2RDF 2 1. The project 3 D2RQ DB-to-RDF mapper written


  1. RDB2RDF mapping with D2RQ and D2R Server Richard Cyganiak Presentation to W3C RDB2RDF WG, 10 Nov 2009

  2. Topics 1. The D2RQ project 2. The D2RQ mapping language 3. Requirements for RDB2RDF 2

  3. 1. The project 3

  4. D2RQ • DB-to-RDF mapper written in Java • In: any JDBC database • Out: SPARQL, Linked Data, ETL, Jena API • GPL, popular, easy to get started • Axiom: We never modify the database 4

  5. The project • Started 2004 (roots: 2002) by Chris Bizer at FU Berlin; later me at FU and HP Labs; today Christian Becker, Andy Langegger • 250+ downloads/month, 8700+ total • mailing list at ~20 msgs/month, 1000+ total • In LOD cloud, LinkedMDB, LODD, TopBraid Composer 5

  6. D2R Server + SPARQL introduced 6

  7. Architecture SPARQL Clients SPARQL D2R Linked Data RDF Server Clients HTML HTML HTTP Browsers D2RQ Mapping File Local Java Application D2RQ Jena/Sesame Non-RDF Engine RDF dump Database Triple Store 7

  8. Architecture (2) • maps DB to virtual RDF graph • easy to offer arbitrary interfaces to the RDF graph • most requested: SPARQL and RDF dumps 8

  9. 2. Mapping language 9

  10. Mapping language • N3 based syntax • Very flexible • Language is not trivial, wish we had a GUI • Usual workflow: auto-generate mapping from DB schema, then customize 10

  11. Flexible mappings! • Properties of one class from multiple tables • Several classes in the same table • Value translations, SQL expressions • Arbitrary joins and SQL conditions 11

  12. To SQL or not to SQL? • Users want to deal with complexity by using their SQL knowledge • They want to write arbitrary SQL queries • We don’t want to parse SQL (painful, DB differences) • We force users to decompose their query into small fragments 12

  13. Mapping process 1. Define DB connection 2. Define your entities 3. Add properties to entites 4. Link entities together 5. Advanced stuff: conditions, joins, value translations 13

  14. 1. Define DB connection 14

  15. map:MyDatabase a d2rq:Database; d2rq:jdbcDSN "jdbc:mysql://localhost/mydb"; d2rq:jdbcDriver "com.mysql.jdbc.Driver"; d2rq:username "user"; d2rq:password "password". 15

  16. 2. Define your entities 16

  17. map:People a d2rq:ClassMap; d2rq:uriPattern “http://.../people/@@User.ID@@”. (SQL fragments in red) 17

  18. map:People a d2rq:ClassMap; d2rq:uriPattern “http://.../people/@@User.ID@@”; d2rq:condition “User.deleted=0”. 18

  19. map:People a d2rq:ClassMap; d2rq:bNodeIdColumns “User.ID”; d2rq:condition “User.deleted=0”. 19

  20. 3. Add properties to entities 20

  21. map:People a d2rq:ClassMap; d2rq:uriPattern “http://.../people/@@User.ID@@”; d2rq:condition “User.deleted=0”; d2rq:class foaf:Person . (SQL fragments in red, RDFS/OWL vocabulary in blue) 21

  22. map:People a d2rq:ClassMap . map:name a d2rq:PropertyBridge; s d2rq:belongsToClassMap map:People; p d2rq:property foaf:nick; o d2rq:column “User.name”. map:mbox a d2rq:PropertyBridge; s d2rq:belongsToClassMap map:People; p d2rq:property foaf:mbox; o d2rq:uriPattern “mailto:@@User.email@@”. 22

  23. map:mbox_sha1 a d2rq:PropertyBridge; d2rq:belongsToClassMap map:People; d2rq:property foaf:mbox_sha1sum; d2rq:sqlExpression “SHA1(CONCAT(‘mailto:’, User.email))”. 23

  24. 4. Link your entities 24

  25. map:Photos a d2rq:ClassMap; d2rq:uriPattern “http://.../photo/@@Photo.ID@@”; d2rq:class foaf:Image . 25

  26. map:photo a d2rq:PropertyBridge; d2rq:belongsToClassMap map:People; d2rq:property foaf:made; d2rq:uriPattern “http://.../photo/@@Photo.UserID@@”. (Photo.UserID is a foreign key to User.ID) 26

  27. Better, less repitition map:photo a d2rq:PropertyBridge; d2rq:belongsToClassMap map:People; d2rq:property foaf:made; d2rq:join “User.ID = Photo.UserID”; d2rq:refersToClassMap map:Photos . 27

  28. Better, less repitition map:photo a d2rq:PropertyBridge; d2rq:belongsToClassMap map:People; d2rq:property foaf:made; d2rq:join “User.ID = Photo.UserID”; d2rq:refersToClassMap map:Photos . (also d2rq:alias for self-joins) 28

  29. Mapping file overview dcmi:Text :class map:title_PropertyBridge dc:title :property :column "Paper.title" :belongsToClassMap map:abstract_PropertyBridge dc:description :property :column "Paper.abstract" map:Paper_ClassMap :uriPattern "/docs/@@Paper.ID@@" map:weblink_PropertyBridge owl:sameAs :property :uriColumn "Paper.weblink" map:author_PropertyBridge dc:creator :dataStorage :property :join "Paper.author=Author.ID" map:Database foaf:Person :class :dataStorage :refersToClassMap :belongsToClassMap map:name_PropertyBridge foaf:name :property :pattern "@@Author.first@@ @@Author.last@@" map:Author_ClassMap :uriPattern "/people/@@Author.ID@@" map:email_PropertyBridge foaf:mbox :property :uriPattern "mailto:@@Author.email@@" 29

  30. 3. RDB2RDF Requirements 30

  31. Syntax? • Turtle, XML, SPARQL-like, SQL-like? • Should be human-writable • Would like to avoid parsing SQL • “SQL Query + RDF template” vs. “RDF Graph + SQL fragment” 31

  32. Expressivity? • Arbitrary SQL for value transforms and conditions • Dynamic properties • Char-separated lists within values • Transformation tables (for type codes) 32

  33. DB compatibility? • Syntax rules for table/column names (espacing, case sensitivity) • Datatypes • Extension functions • “AS”, “LIMIT”, “CONCAT” 33

  34. Links • D2RQ homepage http://www4.wiwiss.fu-berlin.de/bizer/d2rq/ • D2RQ manual & language spec http://www4.wiwiss.fu-berlin.de/bizer/d2rq/spec/ • Mailing list d2rq-map-devel@lists.sourceforge.net 34

Recommend


More recommend