Hi. I'm working on project in which are loading electronic medical information from multiple practices into free version of GraphDB 8.0. If you are curious, the practice data is modeled using NDPBRN ontology found at https://github.com/wdduncan/NDPBRN.

For each set practice data, we load the practice data using the same base uri, but assign a different context uri. For example, for two practices, we are loading the data like so:

practice 1:
base uri: http://www.dental-practices.org
context: http://www.dental-practices.org/practice-1

practice 2:
base uri: http://www.dental-practices.org
context: http://www.dental-practices.org/practice-2

Our goal is to be able to query all the practice data together, and a particular practice when needed. For example, this is a query for all crowns preformed at both practices:

select (count(?crown) as ?totalcrowns)
where { ?crown rdf:type obo:OHD_0000033 . } # crown procedure uri

and this is a query for crowns performed at a particular practice:

select (count(?crown) as ?totalcrowns)
from http://www.dental-practices.org/practice-1
where { ?crown rdf:type obo:OHD_0000033 . } # crown procedure uri

However, we are unsure whether the owl file used to model the data (NDPBRN.owl) needs to be loaded each time we load a set of practice data. That is, when we import a set of practice data do we also need to import the NDPBRN.owl file into the context as well? This doesn't sound right to me, since we would be importing the NDPBRN.owl file multiple times. If not, should the NDPBRN.owl file have its own context? Or should it not have a context so that is always part of the default graph?

Also, we are getting inconsistent behavior from our queries. Sometimes the queries do not return any results, and if we use a "from named" clause we don't get any results too. E.g.:

select (count(?crown) as ?totalcrowns)
from named http://www.dental-practices.org/practice-1
where { ?crown rdf:type obo:OHD_0000033 . } # crown procedure uri

Lastly, are the inferred statements already included in the practice specific contexts?

Sorry for all the questions ...

Thanks, Bill

asked 26 Jan, 21:43

Bill%20D's gravatar image

Bill D
accept rate: 0%

Hi Bill,

first, this list is kept only as an archive, it is not very active and no one is actually monitoring it actively... a better way to get support is to use stackexchange with the 'graphdb' tag

About your question, looks like there is some misunderstanding on what an RDF dataset is and how exactly to query various bits of information that span across several (including the default where all the inferred data is stored in graphdb).

Suggest a quick, fresh read of the sparql specs related to the topic at https://www.w3.org/TR/sparql11-query/#rdfDataset

So in general, the approach should be to have something about instances you like to look at for these practices (if different) which is explicitely stored in such a practics-specific context. That is to be able to 'filter' instances based on the context in which those are defined then 'lookup' for the rest of the data depending where it is. e.g.:

if we have a simple ontology with some instance data placed in 'regions' (which should be simmilar to what you are trying to do/model - or at least it is how I understand it). Like the one from the trig rdf file quoted below ...

As you coudl see, the data is grouped in two sample contexts named :region-1 and :region-2. Each have some explicit relations which derive an inferred class membership for classes :Red, :White, :RedWine and :WhiteWine based on the color or whatever etc.

    @base <http://test.org/base> .
@prefix : <http://test.org/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

:color a rdf:Property .
:red a :Color .
:white a :Color .

:Red a owl:Class;
     owl:equivalentClass [ 
    a owl:Restriction ; 
    owl:onProperty :color;
    owl:hasValue :red 
    ] .

:White a owl:Class;
     owl:equivalentClass [ 
    a owl:Restriction ; 
    owl:onProperty :color;
    owl:hasValue :white 
    ] .

:Wine a owl:Class .

:RedWine owl:intersectionOf (:Wine :Red) .
:WhiteWine owl:intersectionOf (:Wine :White) .

:Car a owl:Class .

:RedCar owl:intersectionOf (:Car :Red) .
:WhiteCar owl:intersectionOf (:Car :White) .

:region-1 {
    :Merlot a :Wine ; :color :red .
    :Traminer a :Wine ; :color :white .
    :Guness a :Beer ; :color :dark .
    :Ferrari a :Car; :color :red .

:region-2 {
    :Caberne a :Wine ; :color :red .
    :Muscat a :Wine ; :color :white .
    :Rose a :Wine ; :color :pink .
    :Beetle a :Car; :color :white .

then you may query the data knowing that all inferred rdf:type relations are placed in the 'default' graph (e.g. one without context identifier) and all relevant explicit rdf:type relations are stored in some context. E.g if we like to find 'All things white' from :region-2 a query like that will do:

PREFIX : <http://test.org/>
select * {
    graph :region-2 {?w a ?class}
    ?w a :White

if we like only the red wines from region-1, then:

PREFIX : <http://test.org/>
select * {
    graph :region-1 {?w a :Wine}
    ?w a :RedWine

if you like to use 'from' and 'from named' you should mind that 'from' cluse form a new dataset for the statement patterns with 'default' scope (e.g. which DO NOT appear in a 'GRAPH <somethin> { }' group, while 'from named' defines a set of contexts to be matched by such statement patterns that appear in the 'Named graph scope' e.g. those within 'GRPAH <somethin> { }' group ...

by default the 'default set' is an union of all data including. The inferred the 'named graph set' is an union of all contexts e.g. all explicit statementn that appear in some context will match.

GraphDB uses two 'special' contexts that could be used to reffer to explict statements http://www.ontotext.com/explicit and for the inferred http://www.ontotext.com/implicit

so a query that finds all things red from region-1 and region-2 may look like (in case we have more regions only those two regions will be matched):

PREFIX : <http://test.org/>
PREFIX onto: <http://www.ontotext.com/>
select * 
from onto:implicit
from named :region-1
from named :region-2
    graph ?g {?w a ?class}
    ?w a :Red

for more information - please look at the online documentation where these a discussed in more detail

Hope that helps you a bit


answered 27 Jan, 03:30

Damyan%20Ognyanov's gravatar image

Damyan Ognyanov ♦♦
accept rate: 25%

Thanks for your help!

(27 Jan, 09:30) Bill D
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 26 Jan, 21:43

Seen: 382 times

Last updated: 27 Jan, 09:30

powered by BitNami OSQA