maps to a class ProjectType, with a data type
property say type that uses string as its range.
CREATE DOMAIN ProjectType AS VARCHAR
↓
<owl:Class rdf:ID=”ProjectType”>
<owl:DatatypeProperty rdf:ID=”type”>
<rdfs:range
rdf:resource=”&xsd;string”/>
</owl:DatatypeProperty>
</owl:Class>
Figure 6: Domain maps to class.
A domain ProjectType in Figure 7 is defined
as the data type of all strings, again. However, there
is now a constraint CHECK on it. This constraint
specifies the domain ProjectType through a list
of values Software and Hardware (also known
as enumeration). Therefore, it maps to an
enumerated class ProjectType, with individuals
for each value in the list.
CREATE DOMAIN ProjectType AS VARCHAR
CONSTRAINT ProjectType_Constraint
CHECK IN (‘Software’, ‘Hardware’)
↓
<owl:Class rdf:ID=”ProjectType”>
<owl:oneOf rdf:parseType=”Collection”>
<owl:Thing rdf:about=”#Software”/>
<owl:Thing rdf:about=”#Hardware”/>
</owl:oneOf>
</owl:Class>
Figure 7: Domain maps to enumerated class.
3.3 Mapping Columns
A column that is not (part of) a foreign key maps to
a data type property unless it uses a domain as its
data type. Then it maps to an object property. This is
because the domain maps itself to either a class or an
enumerated class (see Section 3.2).
A column ssn in a table Employee in Figure 8
is not a foreign key. Therefore, this column maps to
a data type property ssn that uses a class
Employee as its domain. This property has a
maximum cardinality of 1, because the column ssn
may have at most one value for each row in the table
Employee (atomicity). Alternatively, the property
ssn could be defined as functional, which is the
same as saying that the maximum cardinality is 1. It
should be noted that if the column ssn were a
surrogate key, it would be ignored. A surrogate key
is internally generated by the relational database
management system using an automatic sequence
number generator or its equivalence; e.g. an
IDENTITY in SQL Server and Sybase, a
SEQUENCE in Oracle and an AUTO_INCREMENT
in MySQL.
CREATE TABLE Employee(
ssn INTEGER CHECK (ssn > 0))
↓
<owl:DatatypeProperty rdf:ID=”ssn”>
<rdfs:domain
rdf:resource=”#Employee”/>
<rdfs:range
rdf:resource=”&xsd;positiveInteger”/>
</owl:DatatypeProperty>
<owl:Class rdf:ID=”Employee”>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty
rdf:resource=”#ssn”/>
<owl:maxCardinality rdf:datatype=
”&xsd;nonNegativeInteger”1/>
</owl:Restriction>
</rdfs:subClassOf>
</owl:Class>
Figure 8: Column maps to data type property.
Most of the mapping of columns has to do with
the mapping of data types from SQL to XSD. Unlike
SQL, OWL does not have any built-in data types.
Instead, it uses XSD (XML Schema Data types).
A column ssn in Figure 8 uses INTEGER as its
data type. Therefore, a data type property ssn could
use integer as its range. However, there is a
constraint CHECK on the column ssn. This
constraint further restricts the range of values for the
column ssn to all integers greater than 0 (i.e. all
positive integers). Therefore, the data type property
ssn uses positiveInteger as its range.
3.4 Mapping Constraints
SQL supports constraints UNIQUE, NOT NULL,
REFERENCES, FOREIGN KEY, PRIMARY KEY,
CHECK, and DEFAULT. However, not all the
constraints can be mapped to OWL. E.g. a constraint
DEFAULT (that defines a default value for a given
column) has no correspondence in OWL. Therefore,
it is ignored.
3.4.1 Mapping Constraints UNIQUE
UNIQUE is a column constraint. It maps to an
inverse functional property.
A constraint UNIQUE in Figure 9 specifies that a
column ssn in a table Employee is unique,
AUTOMATIC TRANSFORMATION OF SQL RELATIONAL DATABASES TO OWL ONTOLOGIES
133