Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
On Directly Mapping Relational
Databases to RDF and OWL
Juan F. Sequeda
Marcelo Arenas
Daniel P. Miranker
Agenda
Direct
Mapping and Property
Direct Mapping DM
Properties of DM
Extended DM
Conclusion
Direct Mapping
A
direct mapping is a default and
automatic way of translating a relational
database to RDF.
A direct mapping M is a total function
from RC to G.
RC is the set of all triples of the form(R,Σ,I)
R is relational schema
Σ is a set of PKs and FKs over R
I is an instance of R
G is the set of all RDF graph
Fundamental Properties
Information
If direct mapping does not lose any
information about the relational instance
being translated.
Query
Preservation
Preservation
if every query over a relational database
can be translated into an equivalent query
over the RDF graph resulting from the
mapping.
Desirable Properties
Monotonicity
if we insert new data to the database,
then the elements of the mapping that are
already computed are unaltered.
Semantics
Preservation
A direct mapping is semantics preserving
if the satisfaction of a set of PKs and FKs
by a relational database is encoded in the
translation process.
Direct Mapping DM
Storing
relational databases
Storing an ontology
Translating relational schemas into OWL
Translating database instances into RDF
Example
Storing relational databases
REL(r)
ATTR(a,r)
e.g. PK("SID","STUDENT")
FK(a,r,b,s)
e.g. ATTR("NAME","STUDENT")
PK(a,r)
e.g. REL("STUDENT")
e.g. FK("CODE","COURSE","DID","DEPT")
VALUE(v,a,t,r)
e.g. VALUE("1","SID","id1","STUDENT")
Storing an ontology
Class(c)
c is a class
OPn(p1,…,pn,d,r)
p1,...,pn (n ≥ 1) form an object property
with domain d and range r.
DTP(p,d)
p is a data type property with domain d.
Storing an ontology(cont'd)
Identifying
binary relations:
BINREL(R,A,B,S,C,T,D)←
PK(A,B,R),¬THREEATTR(R),
FK(A,R,C,S),R≠S,
FK(B,R,D,T),R≠T,
¬TWOFK(A,R),¬TWOFK(B,R),
¬ONEFK(A,B,R),¬FKTO(R)
BINREL("ENROLLED","SID","CID",
"STUDENT","SID","COURSE","CID")
Storing an ontology(cont'd)
Identifying
class:
CLASS(X) ← REL(X),¬ISBINREL(X)
ISBINREL(X) ←
BINREL(X,A,B,S,C,T,D)
E.g.
CLASS("DEPT")
CLASS("STUDENT")
Storing an ontology(cont'd)
Identifying
object properties:
OP(X,Y,S,T) ←
FK(X,S,Y,T), ¬ ISBINREL(S)
E.g.
OP("CODE","DID","COURSE","DEPT")
Storing an ontology(cont'd)
Identifying
data type properties:
DTP(A,R) ←
ATTR(A,R), ¬ISBINREL(R)
E.g.
DTP("NAME","STUDENT")
Translating schemas into OWL
Generating
IRI
Class
CLASSIRI(R,X) ←
CLASS(R),CONCAT(base,R,X)
E.g.
http://example.edu/db/STUDENT
Data type property
DTP_IRI(A,R,X) ← DTP(A,R),
CONCAT(base,R,"#",A,X)
E.g.
http://example.edu/db/STUDENT#NAME
Translating schemas into
OWL(cont’d)
Generating
IRI
Object property
OP_IRI(R,A,B,S,C,T,D,X) ←
BINREL(R,A,B,S,C,T,D),
CONCAT(base,R,"#",A,",",B,",",C,",",D,X)
E.g.
http://example.edu/db/ENROLLED#SID,CID,SID,CID
OP_IRI(X,Y,S,T,X) ←
OP(X,Y,S,T),
CONCAT(base,S,",",T,"#",X,",",Y,X)
E.g.
http://example.edu/db/COURSE,DEPT#CODE,DID
Translating schemas into
OWL(cont’d)
Translating
relational schemas
Class
TRIPLE(U,"rdf:type","owl:Class") ←
CLASS(R),CLASSIRI(R,U)
Data type property
TRIPLE(U,"rdf:type","owl:DatatypeProperty") ←
DTP(A,R), DTP_IRI(A,R,U)
TRIPLE(U,"rdfs:domain",W) ←
DTP(A,R), DTP_IRI(A,R,U), CLASSIRI(R,W)
Translating schemas into
OWL(cont’d)
Translating
relational schemas
Object property
TRIPLE(U,"rdf:type","owl:ObjectProperty") ←
OP(X,Y,S,T),OP_IRI(X,Y,S,T,U)
TRIPLE(U, "rdfs:domain",W) ←
OP(X,Y,S,T),OP_IRI(X,Y,S,T,U),CLASSIRI(S,W)
TRIPLE(U, "rdfs:range",W) ←
OP(X,Y,S,T),OP_IRI(X,Y,S,T,U),CLASSIRI(T,W)
Translating instances into RDF
Generating IRI
ROWIRI(V,A,T,R,X) ←
PK(A,R), VALUE(V,A,T,R),
CONCAT(base,R,"#",A,"=",V,X)
E.g.
Given VALUE("1","SID","id1","STUDENT") and
PK("SID","STUDENT"),the IRI is:
http://example.edu/db/STUDENT#SID=1
BLANKNODE(T,R,X) ←
VALUE(V,A,T,R), CONCAT("_:",R,T,X)
Translating instances into
RDF(cont’d)
Translating relational instances
CLASS
TUPLEID(T,R,X) ←
CLASS(R),PK(A,R),
VALUE(V,A,T,R),ROWIRI(V,A,T,R,X)
TUPLEID(T,R,X) ←
CLASS(R),¬HASPK(R),
VALUE(V,A,T,R),BLANKNODE(T,R,X)
TRIPLE(U,"rdf:type",W) ←
VALUE(V,A,T,R),TUPLEID(T,R,U),CLASSIRI(R,W)
E.g.
TRIPLE("http://example.edu/db/STUDENT#SID=1",
"rdf:type",
"http://example.edu/db/STUDENT")
Translating instances into
RDF(cont’d)
Translating relational instances
Object Property(from BINREL)
TRIPLE(U,V,W) ←
BINREL(R,A,B,S,C,T,D),
VALUE(V1,A,T1,R),VALUE(V1,C,T2,S),
VALUE(V2,B,T1,R),VALUE(V2,D,T3,T),
TUPLEID(T2,S,U),
OP_IRI(R,A,B,S,C,T,D,V),
TUPLEID(T3,T,W)
E.g.
TRIPLE("http://example.edu/db/STUDENT#SID=1",
"http://example.edu/db/ENROLLED#SID,CID,SID,CID",
"http://example.edu/db/COURSE#CID=1")
Translating instances into
RDF(cont’d)
Translating relational instances
Object Property(from FK)
TRIPLE(U,V,W) ←
OP(A,B,S,T),
VALUE(V1,A,T1,S),VALUE(V1,B,T2,T),
TUPLEID(T1,S,U),
OP_IRI(A,B,S,T,V),
TUPLEID(T2,T,W)
E.g.
TRIPLE("http://example.edu/db/COURSE#CID=1",
"http://example.edu/db/COURSE,DEPT#CODE,DID",
"http://example.edu/db/DEPT#DID=1")
Translating instances into
RDF(cont’d)
Translating relational instances
Data type Property
TRIPLE(U,V,W) ←
DTP(A,R),VALUE(W,A,T,R),
W≠NULL,TUPLEID(T,R,U),DTP_IRI(A,R,V)
E.g.
TRIPLE("http://example.edu/db/STUDENT#SID=1",
"http://example.edu/db/STUDENT#NAME",
"John")
Properties of DM
Information
preservation
Query preservation
Monotonicity
Semantics preservation
Query Preservation of DM
Translate
relational algebra into
equivalent SPARQL query
selection projection rename join union
difference
SPARQL query generated by
Semantics Preservation of DM
Example
of PK violation
T1.SID = 1, T1.NAME = John
T2.SID = 1, T2.NAME = Peter
Database
is inconsistent
Resulting RDF graph is consistent
DM is not semantics preserving.
Extended DM: DMpk
Extended rules
TRIPLE(a,"owl:differentFrom",a) ← PK(X,R),
VALUE(V,X,T1,R),VALUE(V,X,T2,R),T1 ≠ T2
TRIPLE(a,"owl:differentFrom",a) ←
PK(X,R),VALUE(V,X,T,R),V = NULL
Properties of DMpk
Information preservation
Query preservation
Monotonicity
Semantic preservation if considers only PKs
Extended DM: DMpk+fk
Extended rules
VIOLATION(S) ← FK(X,S,Y,T),
VALUE(V,X,T,S),V ≠ NULL,
¬ISVALUE(V,Y,T)
TRIPLE(a,"owl:differentFrom", a) ←
VIOLATION(S)
Properties of DMpk+fk
Information preservation
Query preservation
Monotonicity
Semantic preservation
Conclusion
Direct
mapping DM
Information preservation
Query preservation
Monotocity
Extended
DM
DMpk
DMpk+fk
“No
monotone direct mapping is
semantics preserving”
The End