Virtuoso Open-Source Wiki
Virtuoso Open-Source, OpenLink Data Spaces, and OpenLink Ajax Toolkit
Advanced Search
Location: / Dashboard / Main / VOSIndex / VOSSQL2RDF / VOSSQL2RDFMappingExample

Mapping Example

This example follows in an excerpt from an actual mapping of the phpBB3 SQL schema to the classes defined by the SIOC and FOAF ontologies:

-- SPARQL keyword which is the SPARQL cue for the SQL processor


-- PREFIX declarations

PREFIX  sioc:  <>
PREFIX  sioct: <>
PREFIX  atom:  <>
PREFIX  rdfs:  <>
PREFIX  foaf:  <>
PREFIX  dc:    <>
PREFIX  dct:   <>
PREFIX  skos:  <>
PREFIX  geo:   <>
PREFIX  bm:    <>
PREFIX  exif:  <>
PREFIX  ann:   <>
PREFIX  phpbb: <>

-- Remove prior mappings 
DROP QUAD MAP GRAPH IRI ("http://^{URIQADefaultHost}^/phpBB3_v/") .

-- Declare the special Virtuoso-URI-Generator functions for later use in actual mappings

CREATE IRI CLASS  phpbb:site_iri     
    ( IN  dummy       VARCHAR NOT NULL ) .
CREATE IRI CLASS  phpbb:user_iri
    ( IN  user_name   INTEGER NOT NULL ) .
CREATE IRI CLASS  phpbb:usergroup_iri
    ( IN  group_name  INTEGER NOT NULL ) .
CREATE IRI CLASS  phpbb:forum_iri
    ( IN  forum_id    INTEGER NOT NULL ) .
CREATE IRI CLASS  phpbb:post_iri
    ( IN  post_id     INTEGER NOT NULL ) .

-- Start the actual mapping declaration process
-- Identify Quad Storage Partition within Quad Store

ALTER QUAD STORAGE virtrdf:DefaultQuadStorage

-- Declare Named Graph URI / IRI associated with previously declared Quad Storage partition

    CREATE virtrdf:phpBB3 AS GRAPH IRI ("http://^{URIQADefaultHost}^/phpBB3_v/")

-- Use SPARQL / Turtle Graph patterns to declare:
-- mappings between Table and a RDF Schema or Ontology Class
   # Default phpBB Space
   phpbb:site_iri (PHPBB3.phpBB.phpBB3_site_rdf.WS_DUMMY)
   a sioc:Space ;

--- mappings between Columns in a Table with Attributes of a RDF Schema or Ontology Class
   dc:title WEB_TITLE .

-- The combined data from each mapped column (row) is used to generate an instance (Entity/Individual) of this RDF Schema or Ontology Class 
-- Repeat the process for Each Table being mapped

   # User
   phpbb:user_iri (PHPBB3.phpBB.phpBB3_users_rdf.username)
     a                sioc:User ;
     sioc:id          user_id ;
     sioc:name        username ;
     sioc:email       E_MAIL ;
     sioc:email_sha1  E_MAIL_SHA1 ;
     sioc:has_space   phpbb:site_iri(WS_DUMMY) .

   # Usergroup
   phpbb:usergroup_iri (PHPBB3.phpBB.phpBB3_usergroups_rdf.group_name)
     a          sioc:Usergroup ;
     sioc:id    group_id ;
     sioc:name  group_name .

Powered By Virtuoso