Generating of RDF graph from a relational database using Jena API Jamal BAKKAS #1 , Mohamed BAHAJ #2 # Department of Mathematics and computer science, University Hassan I, FSTS FST Settat, Km 3, B.P.:57, 7Morocco 1 jbakkas@gmail.com 2 mohamedbahaj@gmail.com Abstract— a great part of the existing data on the web is stored in relational databases (RDB). However, the transition from the traditional web to Semantic web requires new structuring of these data. In this context we propose a method which allows automatic extraction of data from RDB and their restructuring in the form of RDF graphs using the Jena API to make them available for the Semantic Web. This structuring is to create a model of the ontology, and to enrich it from the components of the RDB schema using different classes provided by the Jena API. Subsequently, the created model undergoes a modification using SPARQL queries. Thereafter, we proceed to a set of instantiations (individuals) of these model elements using records data of the RDB to populate the ontology. Finally, we test the preservation of the RDB semantic by interrogating the resulting ontology by SPARQL queries by analogy to querying the RDB by SQL queries. Keyword- Mapping, RDB, ontology RDF, SPARQL, Semantic Web I. INTRODUCTION The need to supply the semantic web, with the data used by the web classic, most of which is stored in RDB, gave birth to a set of research to provide a new representation of the data which allows them to be usable and understandable by robots and web agents. Thus we find works that propose methods for converting existing XML document into languages that allow the knowledge representation such as RDF/RDFS or OWL [1]-[4]. Others, interested in mapping of RDB to these languages, given that a large part of data of classic web is stored in these RDB. Among this works we can distinguish two types: the first studies are limited to the conversion at the schema level, Thus, for example, we find proposals to convert UML models to ontologies [5], [6], or extracting schemas from existing RDB by basing on the principle of "reverse engineering" [7]-[9]. The other works, lead studies covering both of schema level and data level such as [10]-[12]. Our approach described in this paper falls into the latter category; it is distinguished by the structuring of the RDF graph elements that we propose to accommodate the RDB data. It begins by creating ontology elements from tables and columns of the database, and then undergoes them to modifications by removing elements created from tables that represent associations (n, n). Next, populate the ontology created by individuals by making assertions of these elements using records data of different tables. These individuals are then connecting each other by making object property assertions using SPARQL queries and foreign key values. The last step is devoted to the validation of our approach. What remains of this paper is organized as follows: in Section 2 we describe our approach in a general way. A more detailed description is provided in Section 3. Section 4 and Section 5 are devoted to the validation of our approach. Finally, we conclude in Section 6. II. METHOD DESCRIPTION Our approach is to generate an ontology from an RDB while keeping the semantics present in the RDB schema and links between records at the data level. We use the catalogs to extract the RDBMS schema RDB, then using the classes provided by the Jena API, we create classes, object properties and data type properties that compose model ontology corresponding to this scheme, the creation of this model must allowed to retain the sense that present the primary keys and foreign keys. Once the model is created we proceed to a modification of the model generated by deleting classes that represent tables whose fields are at the same time primary keys and foreign keys as well as the properties of data type field as having these classes. Then, to preserve the role played by the tables represented by these classes we add, for each class deleted, the object properties directly linking between the classes to which it is linked. To convert the RDB records, we proceed to create individuals which are instances of these classes using the data of RDB records, and we link between these individuals by applying assertions of object properties by taking into account the modifications made to the model. Finally, we test the validity of our approach by the RDF Validator, which checks the syntax of generated documents, and we give some ontology querying examples through SPARL language by analogy to querying the RDB by SQL language. Jamal Bakkas et.al / International Journal of Engineering and Technology (IJET) ISSN : 0975-4024 Vol 5 No 2 Apr-May 2013 1970