Warning:
This wiki has been archived and is now read-only.

Default Mapping Description

From RDB2RDF
Jump to: navigation, search

Introduction

This document defines a default mapping from a relational database to RDF, which defines an RDF graph representation of the data in a relational database. The default mapping can be considered as the mapping to be used when an RDB2RDF system maps a relational database to RDF without any customization.

Preliminaries: Generating IRIs

In the process of translating relational data into RDF, the default mapping must create IRIs identifying each tuple and the attributes in the different tables. A stem IRI should be the start point, such as http://www.example.com/DB. The following IRIs must be created:


The output of the default mapping

In this section, we give a description of the different components of the RDF triples that are generated by the default mappings when translating information from a relational database. In the next section, we give a detailed description of the steps in the generation of these RDF triples, which includes all the cases that are considered in the default mapping in order to properly represent the information stored in the keys and foreign keys of a relational database.

The default mapping translates each table in a relational database into RDF, considering the schema and the tuples of the table. Each tuple in the relational database produces a set of triples with a subject, predicate and object composed as follows:

  • Literal Triples: Each column that is not part of a foreign key and with a non-null value in the tuple generates a triple with the following:
    • Subject: the “Tuple IRI” for the tuple (as described in Section 2)
    • Predicate: the “Column IRI” for the column (as described in Section 2)
    • Object: an RDF Literal for the value of the tuple in the column, with an XML Schema datatype corresponding to the SQL datatype of that column
  • Reference Triples: Columns that are foreign keys and with non-null values in the tuple generate triples with the following:
    • Subject: the “Tuple IRI” for the tuple (as described in Section 2)
    • Predicate: the “Column IRI” for the columns participating in the foreign key (as described in Section 2)
    • Object: the Tuple IRI for the corresponding referenced tuple (according to the foreign key)


The translation process: A detailed description

The default mapping of RDB to RDF must consider all the possible combinations of keys and foreign keys in relational databases. Next, we show how the default mapping works, and how the possible combinations of keys and foreign keys are taken into consideration in this mappings.

The first step of the translation process: Representing the information in primary keys

In its first step, the default mapping considers each table in a relational database separately, generating an RDF triple from each tuple in the table according to the following two cases:

Table has a primary key: Each column that is not part of a foreign key and with a non-null value in the tuple generates a “Literal Triple” (as described in Section 3). The subject of this triple is the “Tuple IRI” for the tuple, which is generated according to the rule “Table with a primary key” in Section 2.

@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://foo.example/DB/People/ID.7#_> <http://foo.example/DB/People#ID> 7 .
<http://foo.example/DB/People/ID.7#_> <http://foo.example/DB/People#fname> "Bob"^^xsd:string .

Table does not have a primary key: Each column that is not part of a foreign key and with a non-null value in the tuple generates a “Literal Triple” (as described in Section 3). The subject of this triple is the “Tuple IRI” for the tuple, which is generated according to the rule “Table without a primary key” in Section 2.

_:a <http://foo.example/DB/Tweets#tweeter> <http://foo.example/DB/People/ID.7#_> .
_:a <http://foo.example/DB/Tweets#when> "2010-08-30T01:33"^^xsd:dateTime .
_:a <http://foo.example/DB/Tweets#text> "I really like lolcats." .

The second step of the translation process: Representing the information in foreign keys

In the second step, the default mapping considers each table in a relational database separately, generating an RDF triple from each tuple in the table when an attribute is a foreign key.

Attribute is a foreign key and is NOT a primary key: Each column that is a foreign key (hence it will not have null values) will generate a "Reference Triple" (as described in Section 3). The subject of this triple is the "Tuple IRI" for the tuple which is generated according to the corresponding case in Section 2.

<http://foo.example/DB/People/ID.7#_> <http://foo.example/DB/People#addr> <http://foo.example/DB/Addresses/ID.18#_> .

Attribute is a foreign key and is also a primary key: To discuss ...

The third step of the translation process: Representing many-to-many tables

In the third step, the default mapping considers a table that is a many-to-many relationship

To discuss ...

The fourth step of the translation process: other cases

To discuss ...