<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>October</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Mapping from Relational Database to Ontology Based on Initial Model</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Vladislav V. Moiseev</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Ivan A. Zagaichuk</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Ulyanovsk State Technical University</institution>
          ,
          <addr-line>Ulyanovsk</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2020</year>
      </pub-date>
      <volume>1</volume>
      <fpage>0</fpage>
      <lpage>16</lpage>
      <abstract>
        <p>The article describes the ontology compilation from the relational database. The process is based on the model called initial. The model is applicable for the design and redesign of existing software products and tuning of the final ontology, including its size reduction. The described model allows obtaining data from a relational schema. The data can be subsequently used for other more flexible formalizations. Moreover, the model can be extended by new parameters which cannot be derived from the schema but be quite useful for design tasks. The paper brings in a short overview of diferent approaches to ontology compilation based on relational data sources. Additionally, two extra strategies are presented. Finally, the article contains an example of these strategies implementation which is measured by performance tests on two diferent data sources.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;relational data schema</kwd>
        <kwd>data model</kwd>
        <kwd>ontology</kwd>
        <kwd>OWL</kwd>
        <kwd>OWL API</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        the need appears and the initial data required for the compilation of ontology lies in the
relational data storage. Thus, relational storage can be converted to ontological resource due to the
need of resolving contradictions within the redesign process. However, the conversion might
be complicated due to the variability between the initial data source and the result [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. For
example, the process of relational database conversion into ontology (using approached [
        <xref ref-type="bibr" rid="ref4 ref5">4, 5</xref>
        ])
can be compromised by several reasons:
• It seems not possible to extract all data about the subject domain from the relational
model;
• Some elements of the relational model are redundant;
• Each relational schema has features of model representation.
      </p>
      <p>The data extraction of a subject domain from a relational database is high-loaded for large
information systems and represents an additional dificulty.</p>
      <p>Therefore, to simplify the redesign process by ontological analysis, it is recomended to define
the model that provides several abilities of:
• The model transformation into an ontological resource;
• The generation of other formalizations besides ontology;
• The independence of the implementations of relational databases;
• The exclusion of some entities and other elements of a relational data schema without
losing model consistency;
• Supplementation of the relational model with additional properties that may be useful
for the compilation of an ontological resource.</p>
      <p>This model is called an initial because it is a base for further ontology compilation of subject
domain.</p>
    </sec>
    <sec id="sec-2">
      <title>2. The overview of ontology compilation strategies based on relational databases</title>
      <p>
        There are many strategies for transforming relational schemas into an ontology (e.g. the
concept of direct mapping [
        <xref ref-type="bibr" rid="ref8 ref9">8, 9</xref>
        ]). It describes the matching of relation schema structures to
metadata description technology RDF (Resource Description Framework) developed by W3C. The
formal mapping description is also given. The fine-tuning of the initial and result data set
cannot be provided by the model. That fully describes direct mapping.
      </p>
      <p>
        W3C develops another technology named as R2RML [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] for relational schema
transformation into metadata. The schema helps provide the fine-tuning in a comparison with direct
mapping. The W3C recommendation does not contain the formal language description of R2RML.
However, it has various examples of data conversion.
      </p>
      <p>
        There are also works describing the transformation of relational data schemas in ontology,
and not just in RDF metadata. For example, [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ] gives an overview of current developments in
such a transformation. This article also undercovers the main types of entities and the basic
rules of transformation and its own data transformation strategy.
      </p>
      <p>
        The following entity types can be distinguished according to [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ]:
• The strong entities without foreign keys (references);
• The strong entities with foreign keys;
• The weak entities:
– Foreign and primary keys are the same;
– The composite primary key that contains various foreign keys for all fields;
– The composite primary key is and the attributes of the initial entity are not
duplicated in referenced ones;
– The composite primary key is and some simple attributes can be duplicated in
referenced entities.
      </p>
      <p>The categories can be used for the correct definition of transformation rules. For instance,
the entities that have not foreign keys can be converted into ordinary ontology classes.</p>
      <p>
        It is also necessary to take into account the constraints of entities. For example, the NOT
NULL constraint can be specified by MinCardinality in OWL notation, the UNIQUE constraint
can be assigned by InverseFunctionalProperty [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ].
      </p>
      <p>
        Some transformation algorithms from relational DBMS to ontology (e.g. [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]) propose a phased
transition: classification of tables, their mapping, mapping columns to data properties,
mapping relationships and mapping constraints.
      </p>
    </sec>
    <sec id="sec-3">
      <title>3. The description of the initial data model for formation of ontologies</title>
      <p>The initial data model for ontology compilation is denoted as  . Thus, the model can be
expressed as:</p>
      <p>=&lt; ,  &gt;
 = { 1,  2, … ,   } - entities of relational schema
 = { 1,  2, … ,   } - the relations between entities
 - the number of entities
 - the number of relations
(1)</p>
      <p>The entity can be described as:
 - the number of attributes of entity 
 = { 1,  2, … ,   }
 = { 1,  2, … ,   }
- many attributes of entity 
- many constraints of entity 
The entity attribute can be presented as:
  = ( , ,</p>
      <p>)
  = ( ,  , , 
)
is an ordered number of attribute i within the cortege of entity attributes
- the name of attribute which must be unique within the entity
= [ ,  , , ℎ , , 
= { 1,  2, … ,   }
- many additional attribute properties
]
- data type
Additional attribute properties may be as follows:
• maximum length (for string fields);
• maximum number of digits (for integer and decimal numbers);
• number of decimal places (for decimal numbers);
• text description.</p>
      <p>The constraint of entity  can be written as:</p>
      <p>=  ( )
 - many attributes that constraint was applied to
 - the function that defines the type of constraint</p>
      <p>The constraints can be described as follows:
•    is a primary key constraint;
•    is a NOT NULL constraint;
•    is a unique constraint;
(2)
(3)
(4)
•    is a foreign key constraint.</p>
      <p>The entity relations can be described as:
 =  ( ,</p>
      <p>,  , ,  )
is a function that describes the type of relation;
is a foreign key constraint of entity  ;
is a primary key constraint of entity  ;
= { 1,  2, … ,   }</p>
      <p>- many of auxiliary parameters of relation.</p>
      <p>The conclusion that is based on (2), (3) and (5) states the definition of the R relation can be
 =   ◦   ∶ {  ,   } ⊆ 
◦ is the operation of binding entities   and   .</p>
      <p>It is proposed to record the resulting model using the XML markup language using the
fol</p>
    </sec>
    <sec id="sec-4">
      <title>4. Ontology compilation strategies</title>
      <p>There are two proposed options for the ontology compilation:
1. Filling the basic ontology of a relational data warehouse by individuals.
2. Ontology creation with entity classes and subsequent filling by individual records.</p>
      <p>The first approach is the simplest but least flexible. In this case, there is a basic ontology with
the classes “entity”, “relationship”, “entity field”, “procedure”, “procedure argument”,
“presentation”, etc. Object relations are set for the classes. For example, the basic transitive object
property “is part” is defined, which is used for relationships between entities and their fields,
as well as procedures with their own arguments.</p>
      <p>The particular elements of the relational schema are filled into the ontology as individuals
(individuals) with the axioms of class membership (Class Assertion).</p>
      <p>This approach has a significant ability to represent any relational schema while expanding
the initial ontology. This strategy allows for making similar ontologies from software products
of the same subject domains. Thus, they will difer only by sets of individuals and related class
axioms. Finally, that helps to simplify the further analysis for integration systems design.</p>
      <p>The main drawback of this approach appears while expanding the basic ontology. In other
words, a software update is required to provide new individuals in accordance with the initial
schema. Moreover, this approach does not support all the opportunities provided by
ontologies. For example, it is dificult to search for contradictions because the relationships between
entities are represented as individuals, and not as object properties with their attributes.</p>
      <p>The second proposed strategy difers from the first that the initial data model is used as a
base for a separate ontology resource that is not associated with any basic one. In this case, the
ontology classes are entities, procedures, and other elements of the initial relational schema.
The entity relations convert into object properties, the fields of entities, and procedure
arguments are into the data properties. There is also possible to use relational data records to fill
the ontology that are used as individuals for conducting an ontological resource solvability.</p>
      <p>The vantage of this strategy is the flexibility and application of the entire ontological tools.
Although the relational schema does not support all required data for the ontology
compilation, this can be achieved by initial schema extension. For example, it is possible to define the
attributes (e.g. transitivity, symmetry, etc.) of object properties for the initial schema. The
resulting ontology will most fully describe the domain already at the initial stage of compilation.</p>
      <p>The disadvantage of this strategy is the need to supplement the initial schema after it is
obtained from the relational database or to refine the resulting ontology after it is get.</p>
    </sec>
    <sec id="sec-5">
      <title>5. The implementation of the proposed strategies</title>
      <p>Since the chosen strategies include two stages (the formation of the initial model and the
compilation of the ontology), the implementation was also divided into two stages.</p>
      <p>Firstly, a generator and designer of the initial data model have been developed with Visual
C# and Windows Forms technology that allows rapid UI development. Microsoft SQL Server
2012 was chosen as a data management tool based on the relational data paradigm. The DBMS
allows easy access to the description of the data schema. However, the choice of a particular
DBMS was up to the experience of the authors, rather than the significant advantages of the
current DBMS system over analogues. The serialization of the initial model is performed using
the XML language with an attributive approach to the description of the properties of elements.
That also helped to simplify the processes of work with the data model and reduced size of
serialized data.</p>
      <p>Java and OWL API libraries were used for the generation of ontologies. The choice is justified
by the prevalence, simplicity, and open-source type. The software helps to deserialize the initial
models and generates, based on settings, the ontology in OWL XML. The format was chosen
due to its readability, prevalence, and convenient debugging and overview tools (protégé and
others).</p>
      <p>The basic ontology must be opened for the implementation of the first strategy. It is done
using the following code:
OWLOntologyManager manager =</p>
      <p>OWLManager.createOWLOntologyManager();
OWLOntology ontology = manager.loadOntologyFromOntologyDocument(
new File("sql-base-ontology-1.0.0.owl"));
OWLDataFactory df = manager.getOWLDataFactory();</p>
      <p>The following are the main classes of the basic ontology (parts of duplicated code omitted):
final String ontologyIRI = "urn:vladdy-moses.sql-base-ontology";
OWLClass entityTableType = df.getOWLClass(ontologyIRI + "#Table");
// ...</p>
      <p>OWLDataProperty schemaDataProp = df.getOWLDataProperty(</p>
      <p>ontologyIRI + "#schema_name");
// ...</p>
      <p>A named individual is created for each entity of relational storage and the following set of
axioms is applied to it:</p>
      <p>is used to determine the data schema and entity name;
•  is used to assign an entity to an ontology class (for example, an
entity can be a table, view, or procedure).</p>
      <p>A named individual is created for each entity field and the following set of axioms is
determined on it:</p>
      <p>is used to determine the data schema and name of the
is used to assign the relationship to an ontology class;
• 
• 
• 
• 
•</p>
      <p>the entity;
•  is used to describe whether a relation belongs to an
entity field on the one hand and to the primary key of an external entity on the other.</p>
      <p>The new resource will be created in a similar way as in the case with the secondly proposed
strategy.</p>
      <p>The class with axiom DeclarationAxiom is instantiated for each entity.</p>
      <p>Each entity’s property is converted to the data property and supports the next axioms:
is used to determine the domain of the data property.</p>
      <p>Each relationship of the relational model is converted into an object property with the
following axioms:</p>
      <p>is used to determine the domain of an object property.
is used to associate a record with a specific class that describes</p>
      <p>is used for foreign keys;
is used for the calculation of each non-null field.</p>
      <p>This strategy allows generating individuals for each database record based on this relational
schema. In this case, each record has an individual with the following axioms:</p>
      <p>The early presented strategies saving procedures coincide with the saving of the ontology
and occurs as follows:
OWLOntologyManager manager</p>
      <p>= OWLManager.createOWLOntologyManager();
OWLDocumentFormat documentFormat = new OWLXMLDocumentFormat();
manager.saveOntology(ontology, documentFormat,</p>
      <p>IRI.create(new File("result.owl")));</p>
    </sec>
    <sec id="sec-6">
      <title>6. Generation result</title>
      <p>It is necessary to take several databases from various subject areas to test the operability of the
proposed ontology strategies compilation from a relational data schema.</p>
      <p>The data of addresses and houses from the Russian Federal Information Address System,
Ulyanovsk Oblast (denoted as  1) and data of overhaul in Ulyanovsk region (denoted as  2)
will be used. Both relational storages correspond to 3rd normal form. Therefore, there would
not be any dificulties with the compilation of ontologies.
The characteristics of relational storages are presented in table 1.</p>
      <p>After the initial data received, the schemas   1 and   2 are formed and based on  1 and
 2 respectively. Their serialized sizes are 35 Kb and 86 Kb respectively.</p>
      <p>The  1 and  2 strategies were used to generate ontologies and the results are in table 2.</p>
      <p>As it is seen, the size of the compiled ontology many times more than data in DBMS format
(varying from 1.33 to 1.6). Firstly, it depends on the OWL XML format that keeps each of the
axioms as an element of XML language and stores parameters as nested elements. However,
other formats were not capable to minimize the size of the final ontology.</p>
      <p>Obviously, the  2 strategy (assumes generation of entity classes and individual records)
increases the ontology compilation time more than the  1. It is due to the fact that data
extraction from the relational database requires additional time for setting up a connection
and execution of SQL requests. The saving time stays linear to the size of ontology.</p>
    </sec>
    <sec id="sec-7">
      <title>7. Conclusion</title>
      <p>The proposed data model based on ontologies is useful for software products redesign. The
model does not rely on the physical implementation of data storage. Moreover, it owns such
properties as unity and flexibility which help to build ontologies on its base.</p>
      <p>The described strategies that are used for ontology compilation from a relational database
helps to set up this process for systems based on relational data storage. The strategies are
both applicable for the implementation of systems’ interfaces and for ontology compilation.
The ontology can help to find contradictions within schema and data of the database.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <surname>Guarino</surname>
            <given-names>N.</given-names>
          </string-name>
          <article-title>Formal ontology in information systems:</article-title>
          <source>Proceedings of the first international conference (FOIS'98)</source>
          , June 6-8, Trento,
          <string-name>
            <surname>Italy.</surname>
          </string-name>
          (
          <year>1998</year>
          ). pp.
          <fpage>3</fpage>
          -
          <lpage>15</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>Simple</given-names>
            <surname>Object Access</surname>
          </string-name>
          <article-title>Protocol (SOAP) 1.1</article-title>
          ,
          <issue>W3C</issue>
          Note 08 May
          <year>2000</year>
          , Avaliable at: https://www.w3.org/TR/2000/NOTE-SOAP-
          <volume>20000508</volume>
          /.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <surname>Yarushkina</surname>
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Moiseev</surname>
            <given-names>V</given-names>
          </string-name>
          .
          <article-title>Analytical Review of Data Transformation for the Task of Integrating Various Representations on the Example of Ontologies and Relational Databases</article-title>
          .
          <source>CEUR Workshop Proceedings</source>
          , Vol.
          <volume>2413</volume>
          (
          <year>2019</year>
          ). pp.
          <fpage>191</fpage>
          -
          <lpage>197</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <surname>Bumans</surname>
            <given-names>G.</given-names>
          </string-name>
          <article-title>Mapping between Relational Databases and OWL Ontologies: an Example</article-title>
          , Avaliable at: https://www.lu.lv/materiali/apgads/raksti/756_pp_
          <fpage>99</fpage>
          -
          <lpage>117</lpage>
          .pdf.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <surname>Astrova</surname>
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kalja</surname>
            <given-names>A</given-names>
          </string-name>
          .
          <article-title>Mapping of SQL Relational Schemata to OWL Ontologies</article-title>
          , Avaliable at: http://wseas.us/e-library/conferences/2006elounda1/papers/537-
          <fpage>193</fpage>
          .pdf.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <surname>Freitas</surname>
          </string-name>
          ,
          <source>Ricardo André Pereira. "Relational databases digital preservation."</source>
          (
          <year>2013</year>
          ), Avaliable at: https://repositorium.sdum.uminho.pt/bitstream/1822/25655/1/ Ricardo%20Andr%
          <article-title>C3%A9%20Pereira%20Freitas</article-title>
          .pdf
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          <article-title>[7] .edmx File Overview (Entity Framework)</article-title>
          , Avaliable at: https://docs.microsoft.com/enUS/previous-versions/dotnet/netframework-4.0/cc982042(v=vs.100),
          <source>last accessed</source>
          <year>2019</year>
          /04/05.
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>A</given-names>
            <surname>Direct</surname>
          </string-name>
          <article-title>Mapping of Relational Data to RDF</article-title>
          , http://www.w3.org/TR/rdb-direct-mapping/.
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>Sequeda1 J.</given-names>
            ,
            <surname>Arenas</surname>
          </string-name>
          <string-name>
            <given-names>M.</given-names>
            ,
            <surname>Miranker</surname>
          </string-name>
          <string-name>
            <surname>D.</surname>
          </string-name>
          :
          <string-name>
            <given-names>A Completely</given-names>
            <surname>Automatic</surname>
          </string-name>
          <article-title>Direct Mapping of Relational Databases to RDF and OWL</article-title>
          , https://www.researchgate.net/publication/267232319_A_Completely_Automatic _Direct_Mapping_of_Relational_Databases_to_RDF_and_OWL.
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <article-title>R2RML: RDB to RDF Mapping Language</article-title>
          , https://www.w3.org/TR/r2rml/#
          <article-title>dfn-r2rmlmapping-document.</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <surname>Louhdi</surname>
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Behja</surname>
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Alaoui</surname>
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>Transformation Rules For Building OWL Ontologies from Relational Databases</article-title>
          , https://airccj.org/CSCP/vol3/csit3822.pdf.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>