EvaBlomqvist (Talk | contribs) (→Reengineering and Refactoring using Semion) |
EvaBlomqvist (Talk | contribs) (→Reengineering and Refactoring using Semion) |
||
Line 48: | Line 48: | ||
* In the Project Explorer, under your datasource, and the Alignment subcategory, you alignment should now appear. Double click on it to open its related tab. | * In the Project Explorer, under your datasource, and the Alignment subcategory, you alignment should now appear. Double click on it to open its related tab. | ||
* In the overview you can see any annotations related to the ontology you have chosen to align to. And in the SPARQL tab you can query your alignment, however, currently it is empty. Instead go to the Alignment Rules tab. This is where you can now create your alignment, i.e. the transformation rules that brings the data from the RDF model of your database into something expressed using the FOAF model instead. | * In the overview you can see any annotations related to the ontology you have chosen to align to. And in the SPARQL tab you can query your alignment, however, currently it is empty. Instead go to the Alignment Rules tab. This is where you can now create your alignment, i.e. the transformation rules that brings the data from the RDF model of your database into something expressed using the FOAF model instead. | ||
− | * We now want to identify all the persons in the database and set them as instances of FOAF person. If you go back to the tab showing the database, and execute the example SPARQL query in the SPARQL tab, you can see all the RDF triples that were generated. If you scroll down the list you will find the actual data of the persons table, expressed as record instances. For instance, for each entry in the persons table there are two triples looking like this: dbSchema:persons_record_x rdf:type dbs:Record and dbSchema:persons_record_x dbs:isRecordOf dbSchema:persons_table. You should write rules that fetch each such persons_record_x and takes the data it has associated, i.e. through the dbSchema:persons_record_x_datum_x dbs:isDatumOf dbSchema:persons_record_x, and extracts its values, e.g. the first and last name of each person as properties of the new FOAF person you are creating. | + | * We now want to identify all the persons in the database and set them as instances of FOAF person. |
− | * | + | ** If you go back to the tab showing the database, and execute the example SPARQL query in the SPARQL tab, you can see all the RDF triples that were generated. If you scroll down the list you will find the actual data of the persons table, expressed as record instances. For instance, for each entry in the persons table there are two triples looking like this: dbSchema:persons_record_x rdf:type dbs:Record and dbSchema:persons_record_x dbs:isRecordOf dbSchema:persons_table. |
+ | ** You should write rules that fetch each such persons_record_x and takes the data it has associated, i.e. through the dbSchema:persons_record_x_datum_x dbs:isDatumOf dbSchema:persons_record_x, and extracts its values, e.g. the first and last name of each person as properties of the new FOAF person you are creating. | ||
+ | * Go back to the tab of the alignment, and select the Alignment Rules tab. | ||
+ | * At the top you see the list of rules currently inserted in this alignment (at the moment it is empty). Click on the Add-button below the table. | ||
+ | * Give a name to the rule, e.g. foaf_person. Then copy the following text as the content of the rule: | ||
+ | ** | ||
=== Using D2R === | === Using D2R === |
Tutorial | Training:Advanced Ontology Engineering at FOI - 2011 |
---|---|
Title | Reengineering |
Solutions:
In this exercise you will use the Semion tool to reengieer a database table from an example database into RDF, and then to refactor it so that the data is expressed using the FOAF vocabulary.
The database:
host: mysql315.loopia.se
user name: d2r@o45820
password: (given at the course)
database name: ontology_se_db_2
Content: The database contains information about a past ISWC conference, and in one table called "persons" there is information about the people that organized or attended the conference.
Task 1:
Your task is to use Semion to express this data in terms of the FOAF vocabulary, at the following URI: http://xmlns.com/foaf/0.1/
Start Semion from the commandline as follows (from the directory where you unpacked Semion):
Mac: java -jar -Xmx512m -XstartOnFirstThread it.cnr.istc.semion.tool-0.6-SNAPSHOT.one-jar.jar
Windows: java -jar -Xmx512m it.cnr.istc.semion.tool-0.6-SNAPSHOT.one-jar.jar
When the tool starts, the following procedure lets you do the first syntactical transformation (reengineering):
Now, you should try to use D2R to instead create a runtime mapping to the DB, so that you can query the DB using SPARQL.
Task 2:
Use the same database as above, and run the following tutorial: http://sw.cs.technion.ac.il/d2rq/tutorial
The example data is already loaded into the database, but you have to edit the example mapping to reflect the details of the database above. Then you can run the D2R server (with the mapping file in the same directory) and try accessing the DB through SPARQL in your browser.