Hybrid Method for Storing and Querying Ontologies in Databases

The goal of the paper is to present a method based on reversible, information preserving transformations and transformation algorithms between OWL 2 ontology and relational database (OWL2ToRDB). The authors propose the hybrid approach, when a part of ontology constructs is directly represented by relational database structures and another part having no direct correspondences in a relational database is stored in metadata tables. Experimental investigation of the implemented OWL2ToRDB tool has shown that the created method is capable for lossless transformations and obtained database schemas are practically and flexibly usable in information systems. When a number of ontology instances is growing, the proposed method shows better query performance time in comparison with traditional methods when all instances are processed in computer memory. Ill. 7, bibl. 15, tabl. 1 (in English; abstracts in English and Lithuanian).


Introduction
Ontology, previously having been an exclusive subject of research in philosophy, currently more and more often is investigated from a perspective of software and systems engineering.This turn was supported by emerged languages and technologies of Semantic Web: Resource Description Framework (RDF), RDF schema RDFS, and Web Ontology Language (OWL), currently OWL 2 [1].Ontologies are increasingly used in Semantic Web as well as in everyday information systems for their semantic enrichment, intelligence and quality improvement [2,3].Such applications require scalability and performance, efficient storage and manipulation of large scale ontological data.
When ontology based systems were growing in scope and volume, backend storages of ontology reasoners began becoming unsuitable.In such circumstances, storing ontologies in relational databases became the relevant needs for Semantic Web and enterprises.
The goal of the paper is to present a method based on reversible, information preserving transformations and transformation algorithms between OWL 2 ontology and relational database (OWL2ToRDB).The advantages of such transformation are twofold.From the one side, it is desirable to store large ontologies in relational databases as these have ensured the best facilities for storing, updating and querying the information of problem domain.From the other side, the massive amounts of relational data need for exposing them on the Semantic Web along with mapping these data structures to an existing ontology or extracting the corresponding ontology from relational database.
The rest of the paper is structured as follows.Section "Related works" shortly presents the state of the art in the area of storing ontologies in databases.Two following sections present metamodels used in OWL2ToRDB method, its main transformations and principles of constructing transformation algorithms."Method evaluation" section describes method implementation and experiments conducted for method approval.Finally, we present conclusions and future works.

Related works
In connection with emerging needs for storing ontologies, in 2005 the current research was initiated.In that time, methodology for storing ontology in relational databases was still in its infancy [4].Similar methodologies for transforming Entity-relationship and UML conceptual models into relational database (RDB) structures, transformations between UML, RDB and XML schemas etc are well-established and implemented in CASE tools.OMG Ontology Definition Metamodel defines transformations between OWL, RDF, RDFS, UML, ER and other modelling languages [5].One possible way to relate ontologies with relational schemas is to use standard methodologies for generating UML models from OWL ontology descriptions and then relational schemas from UML models.Another way is a direct transformation from OWL into relational schema.
Currently, there are several proposals for transforming ontology into relational databases or vice versa (e.g.[4, 610]); however, all of them have some drawbacks, or are intended for a certain purpose (e.g.ontology manipulation).These approaches fall into three categories: 1) methodologies using one or a few tables for storing ontology and its instances e.g.[4]; 2) storing ontology metamodel e.g.[9]; 3) using different schemas for storing ontology concepts and its instances e.g.[6].First and second approaches do not lose ontology information but they are not suitable for efficient query processing that is one of the main advantages of relational databases.The third approach allows efficient querying but a part of ontological information is lost as existing approaches do not map all ontology concepts to relational schema e.g.[6].
Our research is directed towards connecting ontologies and databases for semantic querying or using in database/semantic applications.That means we aim at obtaining practised relational structures for empowering ontologies with advantages of relational databases; also, we aim at ensuring recovery of ontology and its instances for accessing them by semantic technologies.We propose the hybrid approach, when a part of ontology constructs is directly represented by relational database structures and another part having no direct correspondences in a relational database is stored in metadata tables [11].
For bijective transformations, Ehrig et al. presented a formal proof of the sufficient requirement for reversible bijective transformations [12].This requirement states that the projection of transformation on the source model should cover all source constructs.However, OWL 2 transformation into RDB is not bijective as the most of practical transformations.Stevens has extended this requirement to non-bijective transformations pointing out that all transformations comprising the overall transformation process should be reversible [13].She acknowledges the QVT Relation (QVT-R) language as the most suitable language for defining bidirectional transformations.However, QVT-R does not guarantee the lossless transformations per se, this has to be verified.Therefore, we have defined our transformations in QVT-R but also checked their correctness via an experiment.
On the base of analysis of existing methods for representing ontologies in relational databases, the following quality criteria were formulated: 1) the transformation should be fully automatic, realizable and have provable correctness; 2) it should not lose data, data types and structure of ontology; 3) the obtained relational database should be applicable not only for saving all ontology information, but also practically and flexibly usable in information systems.

Method description
The scenarios of using a method for transforming ontologies into databases and backward can be imagined in the following way.Information system designer, using some ontology tool (e.g.Protégé, Altova Semantic Works, etc), creates formal ontology for required domain.The ontology model is transformed into a relational database and filled with ontology data.RDB client applications may access database and render results to users.Also, OWL applications may access ontology and its instances from the relational database and apply semantic technologies for reasoning and querying ontology data stored in database tables.The input of the method is domain ontology with instances, the output -relational database with data.The direct OWL2ToRDB transformation is defined in such a way that the reverse transformation RDBToOWL2 also is realizable and lossless.
OWL2ToRDB transformation principles are shown in Fig. 1.OWL2ToRDB transformation consists of a set of transformations that were defined in QVT-R language as instances of QVT-R metamodel.They use OWL 2 model (instances of OWL 2 metamodel) as input and produce OWL 2 RDB model as output.Axiom is a main instrument to define OWL 2 semantic constructs.OWL 2 blocks are entities (i.e.classes, object properties, annotation properties, data properties, named individuals, and datatypes) that comprise the vocabulary or signature of ontology.One can declare an entity by stating an axiom.Conversely, annotations have no semantics but serve as a powerful means for associating additional information with ontologies, entities, and axioms.Class axioms are defined by class expressions and can state that some class is a subclass of another class, some classes are equivalent or disjoint, or they comprise a disjoint union.In a similar way, you can define object property axioms etc.
Ontology RDB metamodel was obtained from CWM metamodel by eliminating its procedural components and adding metatables (here represented by a single class Metatable and three of 33 metatables as its subclasses) for preserving ontology elements having no corresponding constructs in the relational model.Mappings of main OWL 2 constructs to RDB schema and metaschema are presented in Table 1 (only a little part of mappings for axioms and restrictions to metatables is shown due to space limits).The overall Metaschema includes 33 metatables; a subset of metatables for OWL 2 classes shown in Fig. 4.  The algorithm parses an OWL 2 file and creates object-oriented model containing classes, object and data properties, axioms, restrictions and all other ontology concepts except individuals and assertions.In the next step, it creates relational OWL 2 metaschema corresponding to object-oriented ontology model.The metaschema always has the same structure that must be filled with information of the particular ontology.The detailed steps of the algorithm may be illustrated by algorithm for transforming classes (Fig. 6).

Fig. 6. Transforming ontology classes into RDB tables
The particular class information is inserted in a metaschema table OWLClasses.The mapping point of RDB schema and metaschema is a unique name of a particular class.In relational schema it is a name of a transformed table of a corresponding class, and in metaschema it is a value of a column className in a table OWLClasses.All other steps of OWL2ToRDB algorithm are implemented in a similar way.

The evaluation of the method
For evaluating the method, the OWL2ToRDB tool prototype was implemented with the use of Protégé OWL plug-in for OWL2 ontology management and Jena API for storing and manipulating ontology in memory.The experiment for evaluating the pursued quality criteria was performed.
For evaluating if the OWL2ToRDB transformation is fully automatic, correct and does not lose data, data types and structure of ontology, vehicle ontology was created having 10 classes, 12 object properties, data properties, 46 individuals, 43 object property and 63 data property assertions, 20 annotations, 90 axioms and restrictions.After performing transformation, all these constructs were saved in RDB schema.
Methods of storing ontologies are evaluated by exploring their querying capabilities [14].For ensuring the reversibility of OWL2ToRDB transformation and applicability of obtained RDB schema for practical applications, the prototype tool was created for extracting ontology from database and querying ontology data.
Usually, querying ontologies is performed in the following way: ontology reasoner (e.g.Pellet) reads ontology, including individuals, from a XML file, and performs queries in a computer memory.In our case, only ontology classes, their hierarchies, object and data properties, axioms and restrictions are extracted into a memory.Individuals are accessed by SQL queries obtained by converting fragments of SPARQL to SQL.Our prototype RDBToOWL2 tool creates ontology model for the reasoner, rewrites SPARQL queries and executes SQL for obtaining results.The algorithm of transforming the database into ontology is based on the previously described OWL2ToRDB transformations.Several types of SPARQL queries were performed with different amounts of OWL 2 individuals.For all analyzed queries results were similar to presented in Fig. 7.As can be seen from this figure, query performance time is similar while the number of individuals is moderate.When this number is growing, RDB based querying performance time remains stable but memory based methods are slackening and even failing after reaching some bound that depends on a size of computer memory.For executed experiments with RDBToOWL2 tool, the query performance time in average was decreased by about 40 in comparison with memory based method, but the benefits of developed method become obvious when the number of individuals is growing.

Conclusions and future works
1.The investigation of scientific literature and practices of ontology engineering has shown that it is desirable to store large ontologies in relational databases but current methods and tools are insufficient for this purpose because they do not preserve all ontological information or do not use all advantages of relational databases.2. Such a method should have the following features: the transformation should not lose data, data types and structure of ontology; the transformation should be fully automatic, realizable and have provable correctness; the obtained relational database should be suitable for practical database and semantic applications.3. The desirable features may be achieved by creating a hybrid method combining direct mapping of ontology concepts to relational schema structures with using metaschema for storing ontology axioms and restrictions having no corresponding elements in relational schema.The goal of the paper is to present a method based on reversible, information preserving transformations and transformation algorithms between OWL 2 ontology and relational database (OWL2ToRDB).The authors propose the hybrid approach, when a part of ontology constructs is directly represented by relational database structures and another part having no direct correspondences in a relational database is stored in metadata tables.Experimental investigation of the implemented OWL2ToRDB tool has shown that the created method is capable for lossless transformations and obtained database schemas are practically and flexibly usable in information systems.When a number of ontology instances is growing, the proposed method shows better query performance time in comparison with traditional methods when all instances are processed in computer memory.Ill. 7, bibl.15, tabl. 1 (in English; abstracts in English and Lithuanian).Straipsnio tikslas -pateikti metodą, apimantį abipuses, informacijos neprarandančias transformacijas ir transformavimo algoritmus, skirtus OWL 2 ontologijoms saugoti reliacinėse duomenų bazėse (OWL2ToRDB).Autoriai sukūrė hibridinį metodą, kuris dalį ontologijos konceptų tiesiogiai vaizduoja reliacinių duomenų bazių struktūromis, o kitus darinius, neturinčius tiesioginių atitikmenų reliacinėje bazėje, saugo metaduomenų lentelėse.Eksperimentinis OWL2ToRDB metodą realizuojančio įrankio tyrimas parodė, kad sukurtas metodas nepraranda ontologinės informacijos, o gautos duomenų bazės schemos yra tinkamos praktiškai taikyti informacinėse sistemose.Kai ontologijos egzempliorių skaičius didėja, šiuo metodu gaunama geresnė užklausų vykdymo trukmė nei metodais, apdorojančiais ontologijos egzempliorius kompiuterio atmintyje.Il. 7, bibl.15, lent. 1 (anglų kalba; santraukos anglų ir lietuvių k.).

Fig. 4 .
Fig. 4. Subset of OWL 2 class metatables Transformation algorithms Algorithm for the overall OWL2ToRDB transformation is presented in Fig. 5.

Fig. 7 .
Fig. 7. Dependency of a sample query performance time from the number of individuals (with ontology load time) when all ontology in kept in memory (MEM) and database (RDB)

Table 1 .
Mappings of main OWL 2 constructs to relational schema and metaschema

Table Row
of OWLClasses metatable SubClassOf Foreign Key Value of foreignKey column superClass in OWLClasses metatable HasKey UniqueKey -ObjectProperty ForeignKey or Table Row of OWLObjectProperties ObjectPropertyDomain Points to Table owning ForeignKey of ObjectProperty Value of foreignKey column objectPropertyDomain in OWLObjectProperties metatable ObjectPropertyRange Points to Table owning PrimaryKey, which is ForeignKey of ObjectProperty Value of ForeignKey column objectPropertyRange in OWLObjectProperties metatable FunctionalObjectProperty ForeignKey of ObjectProperty domain Table Value of column functionalObjectProperty in

. Nemuraite, B. Paradauskas. Hybrid Method for Storing and Querying Ontologies in Databases // Electronics and Electrical Engineering. -Kaunas: Technologija, 2011. -No. 9(115). -P. 67-72.
4. Experimental investigation of the implementedOWL2ToRDB tool with the vehicle ontology has shown that the created method is capable for transforming OWL 2 concepts into RDB structures without a loss of ontology information.
5. The experiments with query processing technique that supplements OWL2ToRDB method have shown the better query performance times than memory-based ontology processing methods because it allows to extract into memory only ontology concepts and access individuals by SQL queries obtained by converting fragments of SPARQL into SQL.6. Future works are directed for providing exhaustive experiments and industrial case studies