Presentation is loading. Please wait.

Presentation is loading. Please wait.

ONTOLOGY ENGINEERING Lab #9 - November 3, 2014. Linking Relational Databases to Ontologies 2  Relational databases are still a common means of storing.

Similar presentations


Presentation on theme: "ONTOLOGY ENGINEERING Lab #9 - November 3, 2014. Linking Relational Databases to Ontologies 2  Relational databases are still a common means of storing."— Presentation transcript:

1 ONTOLOGY ENGINEERING Lab #9 - November 3, 2014

2 Linking Relational Databases to Ontologies 2  Relational databases are still a common means of storing information  An enterprise may have many databases that contain information describing different (but possibly overlapping) portions of their domain  How to achieve a unified view of this information when it is not always possible or desirable to collect it into a single store?

3 Database to Ontology Mapping Languages 3  Such languages provide the ability to  View existing relational data in the RDF data model,  Express in the information in a structure and target vocabulary of the mapping author's choice.  Examples  R2RML - http://www.w3.org/TR/r2rml/  D2RQ - http://d2rq.org/  R2O - http://neon-toolkit.org/wiki/ODEMapster  EDOAL - http://alignapi.gforge.inria.fr/edoal.html

4 D2RQ Mapping Language 4  The homepage can be found at: http://d2rq.org/ and the language specification is available at: http://d2rq.org/d2rq-languagehttp://d2rq.org/ http://d2rq.org/d2rq-language  A D2RQ mapping is an RDF document written in Turtle syntax and expressed using terms in the D2RQ namespace:  http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1 http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1  Basic structure of a mapping:  Database columns are mapped to ontology classes using instances of d2rq:ClassMap  Relations between columns are mapped to ontology properties using instances of d2rq:PropertyBridge

5 D2RQ Mapping File As Class Instances 5 map:database rdf:type d2rq:Database ; jdbc:autoReconnect "true" ; jdbc:zeroDateTimeBehavior "convertToNull" ; d2rq:jdbcDSN "jdbc:mysql://localhost/vast2010" ; d2rq:jdbcDriver "com.mysql.jdbc.Driver" ; d2rq:username "root" ; d2rq:password “abc321". map:Person rdf:type d2rq:ClassMap ; rdfs:label "Person"^^xsd:string ; d2rq:class agent:Person ; d2rq:classDefinitionComment "Hospital Records Person"^^xsd:string ; d2rq:dataStorage map:database ; d2rq:uriPattern "hospitalrecords_Person/@@hospitalrecords.uPatientId@@"^^xsd:string.

6 D2RQ Mapping File as Class Instances 6 map:PersonAge rdf:type d2rq:ClassMap ; rdfs:label "Person age"^^xsd:string ; d2rq:class quality:ChronologicalAge ; d2rq:classDefinitionLabel "Hospital Records Person Age"^^xsd:string ; d2rq:dataStorage map:database ; d2rq:uriPattern "hospitalrecords_PersonAge/@@hospitalrecords.uPatientId@@"^^xsd:string. map:person_Age rdf:type d2rq:PropertyBridge ; rdfs:label "person Age"^^xsd:string ; d2rq:belongsToClassMap map:Person ; d2rq:property ero:has_quality ; d2rq:propertyDefinitionLabel "Person Age"^^xsd:string ; d2rq:refersToClassMap map:PersonAge.

7 D2RQ Mapping File as Class Instances 7 map:person_Age_Value rdf:type d2rq:PropertyBridge ; rdfs:label "person Age Value"^^xsd:string ; d2rq:belongsToClassMap map:PersonAge ; dr2q:column “hospitalrecords.age”^^xsd:integer; d2rq:property info:has_integer_value; d2rq:propertyDefinitionLabel "Person Age"^^xsd:string.

8 Mappings Enable SPARQL Queries of Relational Data 8 SELECT ?person ?agevalue WHERE { ?person rdf:type agent:Person. ?age rdf:type quality:ChronologicalAge. ?person ero:has_quality ?age ?age info:has_integer_value ?agevalue }

9 Installing and Running D2R SPARQL Server 9  Download and unzip the d2rq-0.8.1.zip file (latest version as of 11/03/14)  Create a mapping file in.ttl format and place it into the d2r- server working directory  Open a command prompt and navigate to the working directory of the d2r-server.  Ex: cd “C:\Program Files\d2r-server-v8\d2rq-0.8.1“  Run the d2r-server using this command: d2r-server file_name.ttl (where file_name.ttl is the name of a mapping file you’ve created)  If any, examine the error messages, they're trying to tell you something, most often that there's some syntax errors in your file

10 Installing and Running D2R SPARQL Server 10  If there are no errors, open your browser and enter: http://localhost:2020/snorql/ in the address bar http://localhost:2020/snorql/  If a SPARQL query window doesn't open you've done something wrong, for example make certain that the database is up and running  Use Ctrl-c to stop the d2r server and get back to the command prompt.

11 Other D2RQ Tools 11  The generate-mapping tool creates a mapping file that maps each table to a new RDFS class that is based on the table's name, and maps each column to a property based on the column's name. This mapping file can be used as-is or can be customized.  At the command prompt enter: generate-mapping –o customer_record.ttl –u root –p abc123 jdbc:mysql://localhost/customer_record where -o is the name of the output mapping file -u is the database user name -p is user’s password jdbc:… is the connection string including the name of the mysql database (i.e. customer_record)

12 Other D2RQ Tools 12  The dump-rdf tool outputs the contents of the whole database into a single RDF file. If a mapping file is specified, then the tool will use it to translate the database contents to RDF. If no mapping file is specified, then the tool will use the default mapping of generate-mapping for the translation.  At the command prompt enter: dump-rdf –o dump_customer_record.n3 mapping_file.ttl where - o is the name of the output file “mapping_file.ttl” is the name of the mapping file to be used in generating the output.

13 Other D2RQ Tools 13  The d2r-query tool allows executing SPARQL queries against a relational database from the command line. If a mapping file is specified, then the tool will query the virtual RDF graph defined by the mapping. If no mapping file is specified, then the tool will use the default mapping of generate- mapping for the translation.


Download ppt "ONTOLOGY ENGINEERING Lab #9 - November 3, 2014. Linking Relational Databases to Ontologies 2  Relational databases are still a common means of storing."

Similar presentations


Ads by Google