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

rdb2rdf mapping with d2rq and d2r server
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

RDB2RDF mapping with D2RQ and D2R Server

Richard Cyganiak Presentation to W3C RDB2RDF WG, 10 Nov 2009

slide-2
SLIDE 2

Topics

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

2

slide-3
SLIDE 3
  • 1. The project

3

slide-4
SLIDE 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

slide-5
SLIDE 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

slide-6
SLIDE 6

D2R Server + SPARQL introduced

6

slide-7
SLIDE 7

Architecture

SPARQL RDF HTML Jena/Sesame RDF dump

SPARQL Clients Linked Data Clients HTML Browsers Non-RDF Database

HTTP

Local Java Application Triple Store D2RQ Engine D2R Server

D2RQ Mapping File

7

slide-8
SLIDE 8
  • maps DB to virtual RDF graph
  • easy to offer arbitrary interfaces to the

RDF graph

  • most requested: SPARQL and RDF dumps

Architecture (2)

8

slide-9
SLIDE 9
  • 2. Mapping language

9

slide-10
SLIDE 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

slide-11
SLIDE 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

slide-12
SLIDE 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

slide-13
SLIDE 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

slide-14
SLIDE 14
  • 1. Define DB connection

14

slide-15
SLIDE 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

slide-16
SLIDE 16
  • 2. Define your entities

16

slide-17
SLIDE 17

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

17

slide-18
SLIDE 18

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

18

slide-19
SLIDE 19

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

19

slide-20
SLIDE 20
  • 3. Add properties to entities

20

slide-21
SLIDE 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

slide-22
SLIDE 22

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

22

s p

  • s

p

slide-23
SLIDE 23

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

23

slide-24
SLIDE 24
  • 4. Link your entities

24

slide-25
SLIDE 25

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

25

slide-26
SLIDE 26

map:photo a d2rq:PropertyBridge; d2rq:belongsToClassMap map:People; d2rq:property foaf:made; d2rq:uriPattern “http://.../photo/@@Photo.UserID@@”.

26

(Photo.UserID is a foreign key to User.ID)

slide-27
SLIDE 27

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

Better, less repitition

27

slide-28
SLIDE 28

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)

Better, less repitition

28

slide-29
SLIDE 29

Mapping file overview

:belongsToClassMap :property :property :property :property :property :property :dataStorage :dataStorage :refersToClassMap :join "Paper.author=Author.ID" :uriColumn "Paper.weblink" :column "Paper.abstract" :column "Paper.title" :pattern "@@Author.first@@ @@Author.last@@" :uriPattern "mailto:@@Author.email@@"

map:Database map:title_PropertyBridge map:abstract_PropertyBridge map:author_PropertyBridge map:weblink_PropertyBridge foaf:Person dcmi:Text dc:title dc:description

  • wl:sameAs

dc:creator foaf:name foaf:mbox map:email_PropertyBridge map:name_PropertyBridge

:uriPattern "/docs/@@Paper.ID@@"

map:Paper_ClassMap

:uriPattern "/people/@@Author.ID@@"

map:Author_ClassMap

:belongsToClassMap :class :class

29

slide-30
SLIDE 30
  • 3. RDB2RDF Requirements

30

slide-31
SLIDE 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

slide-32
SLIDE 32

Expressivity?

  • Arbitrary SQL for value transforms and

conditions

  • Dynamic properties
  • Char-separated lists within values
  • Transformation tables (for type codes)

32

slide-33
SLIDE 33

DB compatibility?

  • Syntax rules for table/column names

(espacing, case sensitivity)

  • Datatypes
  • Extension functions
  • “AS”, “LIMIT”, “CONCAT”

33

slide-34
SLIDE 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