EvaBlomqvist (Talk | contribs) (→Reengineering and Refactoring using Semion) |
EvaBlomqvist (Talk | contribs) (→Reengineering and Refactoring using Semion) |
||
Line 44: | Line 44: | ||
* However, so far we have only transformed the source syntactically, so now we want to align the data to the FOAF ontology. Start by right-clicking on the data source in the Project Explorer, and select New, Alignment. | * However, so far we have only transformed the source syntactically, so now we want to align the data to the FOAF ontology. Start by right-clicking on the data source in the Project Explorer, and select New, Alignment. | ||
* In the dialogue that appears, you have to first give the alignment a name. Then you can either select to simply use the OWL vocabulary itself as the basis for your alignment, or you can choose to add your own ontology. We want to align our data to the FOAF vocabulary, hence click on the "new ontology" button. | * In the dialogue that appears, you have to first give the alignment a name. Then you can either select to simply use the OWL vocabulary itself as the basis for your alignment, or you can choose to add your own ontology. We want to align our data to the FOAF vocabulary, hence click on the "new ontology" button. | ||
− | * First you give the ontology and ID and a name (both can be anything you choose, but the ID needs to be unique for the workspace). Then provide the online URI of the ontology, i.e for FOAF you input http://xmlns.com/foaf/0.1/ | + | * First you give the ontology and ID and a name (both can be anything you choose, but the ID needs to be unique for the workspace). Then provide the online URI of the ontology, i.e for FOAF you input http://xmlns.com/foaf/0.1/ Then click Finish. |
− | Then click Finish. | + | |
* Now the ontology appears in the drop-down list under the name you gave it. Select it and then click on Finish. | * Now the ontology appears in the drop-down list under the name you gave it. Select it and then click on Finish. | ||
* 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. |
+ | * The following rule will | ||
=== 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.