Working with the Database Backend in OWL

From Protege Wiki
Revision as of 15:07, April 21, 2008 by Tredmond (talk | contribs) (Making OWL Database projects import OWL Database projects)

Jump to: navigation, search

Working with the Database Backend in OWL

Before you start

First, this example assumes that you have a working mysql database and that there is an available database (which in this case is called protege) in the mysql database.

In addition, the mysql jdbc drivers are available to Protege. To make the drivers available, download the drivers from here, copy the jar file into the Protege installation directory and call it driver.jar. In theory, any jdbc database should work but we have only done testing for mysql, postgres, oracle 9g and the microsoft sql server. The drivers for all of these options can be found here.

Opening an ontology using a web uri

This note will show by example how to convert an owl project and its imports to a database backend project. We will use the proton ontology as an example because it has a few non-trivial imports. The first step is to open it from the web. We start protege and in the welcome screen we select "New Project".

OwlDatabaseBackendProtegeWelcome.png

Note that if Protege is already open and you don't see the welcome screen then you can access the screen below by clicking on the File menu and selecting "New Project".

Now since we want to create a Protege OWL project using a url from the internet, we

  • select Use existing sources,
  • select OWL/RDF Files and
  • click next.

OwlDatabaseBackendCreateNewProject.png

Finally we enter the url (http://proton.semanticweb.org/2005/04/protonu) for the upper Proton ontology and click finish.

OwlDatabaseBackendChooseURLAndFinish.png

Wait a bit and the ontology will come up. When it does, you will see the reason that this ontology was chosen for this demonstration when you unravel the imports in the imports tab. There are two imports (protont and protons) which occur in two different places.

OwlDatabaseBackendProtonUImports.png

Converting a Project to a Database Project

Now we will convert the upper Proton ontology to a database project. To do this click on the Protege File menu and select "Convert Project to Format". In this window select the "OWL / RDF Database" format and click ok.

OwlDatabaseBackendSelectProjectFormat.png

Once you click ok, you will see a dialog with several database settings. You can fill them as shown below. If you don't want to type out the entire path of where to save the project then press the box with a superscript + sign in the upper right hand side of the dialog and Protege will let you browse to where the project file should be saved.

OwlDatabaseBackendSelectDbSettings.png

The jdbc:mysql://localhost/protege is parsed as follows. The jdbc:mysql: prefix says that this url is a mysql jdbc url and that the database can be loaded using jdbc with the mysql drivers. The localhost says that the database is running on the local machine and the protege says to use the mysql protege database (which I confgured using mysql tools before I started.)

Click finish and the database project will be created. Use whatever tool is available and you will find that a table has been added to the mysql database. In addition, it is not difficult to show that this project is an example of a database project importing two owl projects that are loaded from the web. To see this, close protege and save the project, turn off your internet connection and try to reload the database ontology. If you can do this then you will see the following popup dialog

OwlDatabaseBackendUnresolvedImport.png

and you will see the following exception (this is just a small bit of the full exception) on the console.

SEVERE: Exception caught -- java.net.UnknownHostException: proton.semanticweb.org
   at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
   at java.net.Socket.connect(Socket.java:520)
   at sun.net.NetworkClient.doConnect(NetworkClient.java:152)
   at sun.net.www.http.HttpClient.openServer(HttpClient.java:387)
   at sun.net.www.http.HttpClient.openServer(HttpClient.java:522)
   at sun.net.www.http.HttpClient.<init>(HttpClient.java:231)
   at sun.net.www.http.HttpClient.New(HttpClient.java:304)

What these messages mean is that Protege needed to get the imported ontologies from the internet but was unable to find them. The next step is to show how to put all the data on the local machine in the same mysql database so that this ontology can be accessed without requiring an internet connection.

Making OWL Database projects import OWL Database projects

To continue, we must convert the

http://proton.semanticweb.org/2005/04/protont

and the

http://proton.semanticweb.org/2005/04/protons

projects to database projects. For this example we assume that both projects are converted to database projects using the same protege mysql database. However with small changes to the instructions below, one could use other databases for the other two projects including using postgresql or oracle database. In other words it is perfectly feasible for a mysql project to import a postgresql database project.

Important Note!: It is important that different projects using the same database (e.g. protege) use different table names. The diagrams below show the settings that I used for the two databases and it shows that I use the table ProtonTop and ProtonSystem for the table names. OwlDatabaseBackendProtonTSettings.png OwlDatabaseBackendProtonSSettings.png