Professional Documents
Culture Documents
(pp375-380)
Abstract: A novel approach is proposed. This approach maps a relational database defined by a relational
schema to an ontology. The ontology has a hierarchical structure, and it is no longer “impaired” by
optimization and bad database design of the relational schema. The approach can be used for migrating HTML
pages (especially those that are dynamically generated from a relational database) to the ontology-based
Semantic Web.
the primary keys of the two tables, it maps to a pair KEY(employeeID, projectID, skillID))
of object properties: involves and ↓
<owl:Class rdf:ID="Involvement"/>
involvedBy. One object property is the inverse of
another, meaning that the relationship is Figure 10. Mapping composite tables (contd.)
bidirectional; i.e. a project involves an employee.
And an employee is involved in a project.
3.3 Mapping Columns
CREATE TABLE Involvement( The third step of our approach is mapping columns.
employeeID INTEGER REFERENCES Employee, Each column in a table maps to a data type property
projectID INTEGER REFERENCES Project,
CONSTRAINT Involvement_PK PRIMARY
in a class, with the exception of foreign keys.
KEY(employeeID, projectID)) Foreign keys are ignored for a while, as they
↓ represent relationships.
<owl:ObjectProperty rdf:ID="involves"> Example 1. Consider a column projectID in a
<rdfs:domain rdf:resource="#Project"/>
<rdfs:range rdf:resource="#Employee"/>
table Project in Fig. 11. This column maps to a
</owl:ObjectProperty> data type property projectID in a class
<owl:ObjectProperty rdf:ID="involvedIn"> Project.
<owl:inverseOf
rdf:resource="#involves"/>
CREATE TABLE Project(
</owl:ObjectProperty> projectID INTEGER PRIMARY KEY)
Figure 8. Mapping composite tables ↓
<owl:DatatypeProperty rdf:ID="projectID">
<rdfs:domain rdf:resource="#Project"/>
Example 4. Consider a composite table <rdfs:range
Involvement in Fig. 9. Not only does that table rdf:resource="&xsd;integer"/>
</owl:DatatypeProperty>
consist of the primary keys of the two tables, but it
also contains an additional column hours. Figure 11. Mapping columns
Therefore, it maps to a class Involvement and a
pair of object properties for each table participating
in the relationship. (The object properties are not 3.4 Mapping Relationships
shown in Fig. 9 because of a lack of space.) The fourth step of our approach is mapping
relationships. Relationships map to classes, object
CREATE TABLE Involvement(
properties or inheritance, depending on the types of
employeeID INTEGER REFERENCES Employee,
projectID INTEGER REFERENCES Project, key, data and column correlations.
hours INTEGER, Given two tables r1 and r2, there are four types
CONSTRAINT Involvement_PK PRIMARY of:
KEY(employeeID, projectID))
↓
• Key correlation: key equality: K1=K2, key
<owl:Class rdf:ID="Involvement"/> inclusion: K1⊂K2, key intersection:
Figure 9. Mapping composite tables (contd.) K1∩K2≠∅, K1–K2≠∅, K2–K1≠∅ and key
disjointness: K1∩K2=∅
• Data correlation: data equality:
Example 5. Consider a composite table
r1[K1]=r2[K2], data inclusion:
Involvement in Fig. 10. This table represents a
ternary relationship between three tables: r1[K1]⊂r2[K2], data intersection:
Employee, Project and Skill. Since only a r1[K1]∩r2[K2]≠∅, r1[K1]–r2[K2]≠∅,
binary relationship can be represented through a pair r2[K2]–r1[K1]≠∅ and data disjointness:
of object properties, the table maps to a class r1[K1]∩r2[K2]=∅
Involvement and a pair of object properties for • Column correlation: column equality:
each table participating in the relationship. (The C1=C2, column inclusion: C1⊂C2, column
object properties are not shown in Fig. 10 because of intersection: C1∩C2≠∅, C1–C2≠∅, C2–
a lack of space.) C1≠∅ and column disjointness: C1∩C2=∅,
CREATE TABLE Involvement(
where K1 and K2 are primary keys of r1 and r2,
employeeID INTEGER REFERENCES Employee, respectively; C1 and C2 are columns of r1 and r2,
projectID INTEGER REFERENCES Project, respectively; r1[K1]=πK1(r1) and
skillID INTEGER REFERENCES Skill,
CONSTRAINT Involvement_PK PRIMARY
Proceedings of the 6th WSEAS International Conference on Applied Informatics and Communications, Elounda, Greece, August 18-20, 2006 (pp375-380)
budget FLOAT, data in the table have the same value for the column.
dueDate DATE)
CREATE TABLE SoftwareProject(
Therefore, the constraint maps to a functional
projectID INTEGER PRIMARY KEY, property.
budget FLOAT,
dueDate DATE) CREATE TABLE Project(
↓ projectID INTEGER PRIMARY KEY,
<owl:Class rdf:ID="SoftwareProject"> budget FLOAT UNIQUE)
<owl:disjointWith ↓
rdf:resource="#HardwareProject"/> <owl:FunctionalProperty rdf:ID="budget"/>
</owl:Class>
Figure 17. Mapping unique constraints
<owl:Class rdf:ID="Project">
<owl:unionOf rdf:parseType="Collection">
<owl:Class
rdf:about="#SoftwareProject"/>
Example 2. Consider a not null constraint in Fig.
<owl:Class 18. This constraint specifies that a column budget
rdf:about="#HardwareProject"/> in a table Project is not null, meaning that all
</owl:unionOf> data in the table contains values for the column.
</owl:Class>
Therefore, the constraint maps to a minimum
Figure 15. Key equality, data disjointness cardinality of 1.
and column equality
CREATE TABLE Project(
projectID INTEGER PRIMARY KEY,
Example 5. Consider a relationship between budget FLOAT NOT NULL)
HardwareProject and SoftwareProject in ↓
Fig. 16, when key equality, data intersection and <owl:Class rdf:ID="Project">
column equality hold on it. Because some data are <rdfs:subClassOf>
<owl:Restriction>
common to both tables, we create a class Project <owl:onProperty
whose individuals are the intersection of the data of rdf:resource="#budget"/>
the two tables. <owl:minCardinality
rdf:datatype="&xsd;nonNegativeInteger"1/>
CREATE TABLE HardwareProject( </owl:Restriction>
projectID INTEGER PRIMARY KEY, </rdfs:subClassOf>
budget FLOAT, </owl:Class>
dueDate DATE)
Figure 18. Mapping not null constraints
CREATE TABLE SoftwareProject(
projectID INTEGER PRIMARY KEY,
budget FLOAT,
dueDate DATE)
Example 3. Consider a primary key constraint in
↓ Fig. 19. This constraint specifies that a column
<owl:Class rdf:ID="Project"> projectID in a table Project is a primary key.
<owl:intersectionOf Since the primary key implies that the column is
rdf:parseType="Collection"> both unique and not null, the constraint maps to both
<owl:Class
rdf:about="#SoftwareProject"/> a functional property and a minimum cardinality of
<owl:Class 1.
rdf:about="#HardwareProject"/>
</owl:intersectionOf> CREATE TABLE Project(
</owl:Class> projectID INTEGER PRIMARY KEY)
↓
Figure 16. Key equality, data intersection
<owl:Class rdf:ID="Project">
and column equality
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty
3.5 Mapping Constraints rdf:resource="#projectID"/>
<owl:minCardinality
The fifth step of our approach is mapping rdf:datatype="&xsd;nonNegativeInteger">1/>
constraints. Constraints specify if a column in a </owl:Restriction>
table is unique or not null, or if the column is a </rdfs:subClassOf>
primary key or a foreign key. Constraints also </owl:Class>
<owl:FunctionalProperty
specify a data range for the column. rdf:ID="projectID"/>
Example 1. Consider a unique constraint in Fig.
17. This constraint specifies that a column budget Figure 19. Mapping primary key constraints
in a table Project is unique, meaning that no two
Proceedings of the 6th WSEAS International Conference on Applied Informatics and Communications, Elounda, Greece, August 18-20, 2006 (pp375-380)
Acknowledgement
This research is partly sponsored by ESF (Estonian
Science Foundation) under the grant nr. 5766.