# Semantics-Preserving RDB2 RDF Data Transformation Using Hierarchical Direct Mapping
## 4 Hierarchical Mapping Rules
### Rules for General Relational Schemas  
This section defines the rules using Lemmas 1 and 2 to generate accurate RDF data from relational data without information loss (proofs are provided in the Appendices C and D). Lemma 1 describes the feature of the OWL class during the mapping process. * Lemma 1: Suppose \(R\) is a relational table set, \(A\) is an attribute set, \(K\) is an integrity constraint set, \(I\) is a relational instance set, \(X\) is a set where \(X\subset(R\cup A\cup K\cup I)\), and F is a direct mapping function. Then, every \(y\in\text{F}(X)\) by inference from owl:Class can be retrieved. Thus, to avoid Problem 1 described in Section 3.3, Rule 1 for mapping relational tables based on Lemma 1 is defined as follows. * Rule 1: Rel(\(r\)) \(\land\
eg\)BinRel(\(r\), \(a_{1}\),..., \(a_{nt}\), \(s\), \(b_{1}\),..., \(b_{nt}\), \(t\)) \(\rightarrow\) Relation(\(r\)), where the predicates used on the left-hand side are defined in the Appendix A, and Relation(\(r\)) is a predicate that verifies that \(r\) is a relational table and not a binary relation. By Rule 1, relational tables are transformed into semantic resources using Relation (typed OWL class), which is a semantic vocabulary to notate relational tables. For example, if a relational table, \"Student.\" is transformed by a naive rule, \"Rel(Student) \(\rightarrow\) Class(Student),\" then the transformed output _Student_ loses the explicit information indicating that it is a relational table. This loss happens, because all semantic resources are typed only by the OWL class (Figure 9(a)). On the other hand, _Student_ will not lose the information that it is a relational table if Rule 1 is implemented. _Relation_ is defined as a type of _Student_ using Rule 1, which provides explicit information that the RDF data is transformed from a relational table (Figure 9(b)). Lemma 2 illustrates the feature of the OWL object property used to express the semantics of relationships between semantic resources. * Lemma 2: For any \(X\) in relational data, if \(x\in X\) references another \(y\in X\), then \(x\) can be transformed into a semantic resource, which has a type of owl:ObjectProperty. Based on Lemma 2, if a direct-mapping method does not manage the feature of an object property accurately, then Problem 2 described in Section 3.3 can occur during the mapping process. Thus, Rules 2-5 based on Lemma 2 for mapping the semantics of relationships are defined. Rule 2 is composed of five sub rules to specify the attributes within the hierarchical structure:  
* Rule 2: Prop(\(a\), \(r\), \(\land\) FP(\(a\)) \(\rightarrow\) Attr(\(a\), \(r\)) ObjProp(\(a\), \(r\), \(s\)) \(\rightarrow\) FKeyAttr(\(a\), \(r\), \(s\)) DataProp(\(a\), \(r\), type(\(a\))) \(\rightarrow\) NonFKeyAttr(\(a\), \(r\)) \(\forall a\forall r\) FKeyAttr(\(a\), \(r\), \(s\)) \(\forall a\forall r\) Att(\(a\), \(r\)) \(\forall a\forall r\) NonFKeyAttr(\(a\), \(r\)) \(\subseteq\)\(\forall a\forall r\) Att(\(a\), \(r\))  
Figure 10: A comparative example of rules for mapping relational tables (Rule 1). where the predicates on the left-hand side are defined in the Appendix A, and the predicates on the right-hand side represent the transforms of relational attribute a. With these predicates, Rule 2 has a distinct advantage over previous approaches that simply used the OWL object property and the datatype property to map relational attributes. Because the OWL properties are provided to describe any resource with referencing semantics (not just for relational attributes), using only the OWL properties will not always guarantee that the output data was originally attributed data. As a result, previous approaches cannot avoid semantic information loss during mapping attributes. However, Rule 2 adopts hierarchical structured semantic vocabularies on attributes (Figure 11). The vocabularies describe various types of attributes, and each input attribute can be transformed into RDF data with detailed information.