mappingsemantic-webontologyeasyrdf

How to build a PHP webpage using ontology that already mapped to relational database


It's my very first time building for the semantic web.

I'm not sure how to create a PHP webpage and connect it to an ontology which I have mapped to a relational database using the Ontop plugin for Protege.

Has the database become rdfstore?

I have tried using the EasyRdf library to connect the PHP to ontology, however it didn't work.

Here is the php code that I tried.

<?php
require 'vendor/autoload.php';
$foaf = new EasyRdf_Graph("http://localhost/proIT.owl");
$foaf->load();
$me = $foaf->primaryTopic();
echo "My name is: ".$me->get('foaf:name')."\n";
?>

Solution

  • There are 2 main problems here:

    (1) There is no way to access the mappings you have applied from the Protege Ontop plugin from EasyRDF in PHP. The Protege Ontop plugin enables SPARQL queries over your database from Protege, which is not accessible to EasyRDF. Based on the architecture of Ontop, you need to setup a SPARQL endpoint for Ontop which can be done using Sesame workbench. See Sesame SPARQL Enpoint Installation.

    Ontop Architecture

    (2) Now you need EasyRDF to access the SPARQL endpoint. In this regard your PHP code is incorrect in that it merely loads the .owl file rather than querying the SPARQL endpoint. See EasyRDF SPARQL query example for an example on how to do a SPARQL query using EasyRDF.

    Lastly, as for your question whether the database has become an RDFstore, the answer is NO. Your database is not changed. Rather, the Ontop Protege plugin or the repository for Ontop you configure in Sesame Workbench, provides a SPARQL enabled access layer to your database. I.e., you will still be able to do typical SQL queries to your database through your SQL client.