documenting a default mapping

Noting Irina Astrova's "Rules for Mapping SQL Relational Databases to
OWL Ontologies", I suspect it would be useful to write down a base
case transformation from relations to RDF, analogous to D2R's minimal
configuration for relations with single primary keys. Following is an
algebra and an explaination for that:

Suppose we want to RDF-ize a relation R:
  R:relation := (name:string, data:set(T:tuple))†
  T := set (A:attribute)
  attributes := (name:string, value:string, function:null|pk|reference|scalar)
meaning attributes are SQL NULL, a primary key, a foreign key, or
scalar values. (Yes, this minimal mapping precludes attributes from
being both primary AND foreign keys.)

RDFr(R)    := set (RDFt(T) for each T in R.data)
RDFt(T)    := set (RDFl(S, A) for each scalar A in T)
            + set (RDFn(S, A) for each reference A in T) | S = nodemap(pk(T))
RDFl(S, A) := triple (S, predicatemap(A), literalmap(A))
RDFn(S, A) := triple (S, predicatemap(A), nodemap(A))

literalmap produces RDF literal with XSD datatypes with this type
mapping TM:
  SQL  XSD
  INT  http://www.w3.org/TR/xmlschema-2/#integer
  FLOAT  http://www.w3.org/TR/xmlschema-2/#float
  DATE  http://www.w3.org/TR/xmlschema-2/#date
  TIME  http://www.w3.org/TR/xmlschema-2/#time
  TIMESTAMP http://www.w3.org/TR/xmlschema-2/#dateTime
  CHAR  http://www.w3.org/TR/xmlschema-2/#string
  VARCHAR http://www.w3.org/TR/xmlschema-2/#string
  STRING http://www.w3.org/TR/xmlschema-2/#string

literalmap := rdfLiteral(A,value, TM(A.type))

nodemap and predicate map are lexical transformations producing IRIs,
either hash
  nodemap(A):IRI = IRI(stemURI + "/" + R.name "/" A.name + "." + A.value + "#_")
  predicatemap(A):IRI = IRI(stemURI + "/" + R.name "#" A.name)
or slash-compatible:
  nodemap(A):IRI = IRI(stemURI + "/" + R.name "/" A.name + "/" + A.value)
  predicatemap(A):IRI = IRI(stemURI + "/" + R.name "/" A.name)

† A variant of this algebra with the traditional relation definition
    R:relation := (name:string, header:set(D:definition), data:multiset(T:tuple))
  was implemented in scala
    https://dvcs.w3.org/hg/stemGraph/file/4ace3eb848d4/src/main/scala/Main.scala
  but the extra rigor ensuring consistent attributes provides more noise
  than value to this application.


I'd like to get this into a forum for disucssion with rdb2rdf WG and
the broader community. If folks here are interested in this material,
I'll draw up a WG-publishable document. If not, I can make it available
elsewhere. Either way, the feedback will be useful to us.
-- 
-ericP

Received on Monday, 31 May 2010 06:46:30 UTC