You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Joerg Baach <li...@baach.de> on 2012/12/17 16:53:45 UTC

SDB + OWLReasoning

:Hi *,

I am doing my first babysteps with jena/fuseki. What I would like to get
is a fuseki server running that connects to a mysql database and uses an
owl reasoner. After lots of fiddling and googling I got it to run for in
memory and tdb, but sdb still gives me problems. The triples are
inserted into mysql, but on the select I only get dog1 - so the
reasoning doesn't seem to work.

Below my INSERT, SELECT, expectation, results and my configuration.

Any hints what I did wrong in my config?

Thanks a lot,

  Joerg

#######################  INSERT  #################################
PREFIX rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:   <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ex:   <http://example.org/>
PREFIX zoo:   <http://example.org/zoo/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>

INSERT DATA {

ex:dog1    rdf:type         ex:animal .
ex:cat1    rdf:type         ex:cat .
ex:cat     rdfs:subClassOf  ex:animal .
zoo:host   rdfs:range       ex:animal .
ex:zoo1    zoo:host         ex:cat2 .
ex:cat3    owl:sameAs       ex:cat2 .

}

#######################  SELECT  #################################
PREFIX  ex: <http://example.org/>
SELECT ?animal
WHERE
  { ?animal a ex:animal . }

####################### EXPECTED #################################

-----------------------------
| animal                    |
=============================
| <http://example.org/dog1> |
| <http://example.org/cat2> |
| <http://example.org/cat3> |
| <http://example.org/cat1> |
-----------------------------

####################### RESULT #################################
-----------------------------
| animal                    |
=============================
| <http://example.org/dog1> |
-----------------------------

####################### CONFIG #################################

@prefix :        <#> .
@prefix fuseki:  <http://jena.apache.org/fuseki#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:   <http://www.w3.org/2000/01/rdf-schema#> .
@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix sdb: <http://jena.hpl.hp.com/2007/sdb#> .

[] rdf:type fuseki:Server ;

   fuseki:services (
     <#service>
   ) .

# Custom code.
[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
[] ja:loadClass "com.hp.hpl.jena.sdb.SDB" .


<#service>  rdf:type fuseki:Service ;
    fuseki:name              "inf" ;             # http://host/inf
    fuseki:serviceQuery      "sparql" ;          # SPARQL query service
    fuseki:serviceUpdate     "update" ;
    fuseki:dataset           <#dataset3> ;       #select which set to
                                                 #use
    .
#---------------------------------------------------------------------
#In Memory
<#dataset1> rdf:type       ja:RDFDataset ;
    ja:defaultGraph       <#model_inf_1> ;
    .

<#model_inf_1> rdfs:label "Inf-1" ;
        ja:reasoner
         [ ja:reasonerURL
           <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>];
    .

#---------------------------------------------------------------------
# TDB
tdb:GraphTDB    rdfs:subClassOf  ja:Model .

<#dataset2> rdf:type ja:RDFDataset ;
    ja:defaultGraph <#model2>;
    .

<#model2> a ja:InfModel;
    ja:baseModel <#tdbGraph>;
    ja:reasoner
         [ ja:reasonerURL
           <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>];
    .
<#tdbGraph> rdf:type tdb:GraphTDB;
                     tdb:location "DB";
    .

#---------------------------------------------------------------------
sdb:DatasetStore rdfs:subClassOf ja:RDFDataset .
<#dataset3>  rdf:type sdb:DatasetStore ;
    ja:defaultGraph       <#model3> ;
    sdb:store <#store>;
    .

<#model3> a ja:InfModel;
    ja:baseModel <#sdbGraph>;
    ja:reasoner
         [ ja:reasonerURL
           <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>];
    .

<#sdbGraph> rdf:type ja:Model;
   .

<#store> rdf:type sdb:Store  ;
   rdfs:label "SDB" ;
   sdb:layout "layout2" ;
   sdb:engine "InnoDB" ;
   sdb:connection
    [  rdf:type sdb:SDBConnection ;
       sdb:sdbType "MySQL" ;
       sdb:sdbHost "localhost" ;
       sdb:sdbName "fuseki";
       sdb:sdbUser "fuseki";
       sdb:sdbPassword "";
       sdb:driver "com.mysql.jdbc.Driver" ;
    ]
    .



Re: SDB + OWLReasoning

Posted by Andy Seaborne <an...@apache.org>.
On 17/12/12 15:53, Joerg Baach wrote:
> :Hi *,
>
> I am doing my first babysteps with jena/fuseki. What I would like to get
> is a fuseki server running that connects to a mysql database and uses an
> owl reasoner. After lots of fiddling and googling I got it to run for in
> memory and tdb, but sdb still gives me problems. The triples are
> inserted into mysql, but on the select I only get dog1 - so the
> reasoning doesn't seem to work.
>
> Below my INSERT, SELECT, expectation, results and my configuration.
>
> Any hints what I did wrong in my config?

I'm not completely sure but


> #---------------------------------------------------------------------
> sdb:DatasetStore rdfs:subClassOf ja:RDFDataset .
> <#dataset3>  rdf:type sdb:DatasetStore ;

<#dataset3>  rdf:type ja:RDFDataset ;
     ja:defaultGraph       <#model3> ;
     .

I think that needs to be ja:RDFDataset (see the TDB case) because the 
assembler is possibly finding sdb:DatasetStore, making that the dataset 
and so ignoring the ja:defaultGraph and hence the inference engine.

>      ja:defaultGraph       <#model3> ;
>      sdb:store <#store>;
>      .
>
> <#model3> a ja:InfModel;
>      ja:baseModel <#sdbGraph>;
>      ja:reasoner
>           [ ja:reasonerURL
>             <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>];
>      .
>
> <#sdbGraph> rdf:type ja:Model;
>     .

<#sdbGraph> rdf:type sdb:Model ;
     sdb:dataset <#sdbDataset> .

<#sdbDataset> df:type sdb:DatasetStore ;
    sdb:store <#store>;
    .



>
> <#store> rdf:type sdb:Store  ;
>     rdfs:label "SDB" ;
>     sdb:layout "layout2" ;
>     sdb:engine "InnoDB" ;
>     sdb:connection
>      [  rdf:type sdb:SDBConnection ;
>         sdb:sdbType "MySQL" ;
>         sdb:sdbHost "localhost" ;
>         sdb:sdbName "fuseki";
>         sdb:sdbUser "fuseki";
>         sdb:sdbPassword "";
>         sdb:driver "com.mysql.jdbc.Driver" ;
>      ]
>      .
>
>