querying child data-properties on RDF-store

Sergio Source

I have, in my ontology, an entity named "person" that has a class child named "member". Some like this (indenting for indicate the hierarchy),


Also, I have some attributes (dataProperty), associated with "person", and another attributes associated with "member". Specifically, that attributes could be phone numbers. I propose a hierarchy of attributes in this way,

phone (domain: person)
    office-phone (domain: member)
        office-phone-1 (domain: member)
        office-phone-2 (domain: member)
    personal-phone (domain: person)

I'm doing the following,

SELECT ?s ?attr ?data
    value ?attr {:phone} .
    ?s rdf:type :member .
    ?s ?attr ?data .  

to get all phone-numbers,

instance-member   :phone   "value-of-personal-phone"
instance-member   :phone   "value-of-office-phone-1"
instance-member   :phone   "value-of-office-phone-2"


how could I ONLY to get the two office-phone WITHOUT USE the specific attribute ":office-phone"?? Some owl: restriction or definition??




answered 2 weeks ago AKSW #1

First, you have to use the property hierarchy in your data, otherwise, this can't work (it would be good if you provide proper sample data next time...):

@prefix : <http://example.org/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema/> .

:officePhone rdfs:subPropertyOf :phone .
:officePhone1 rdfs:subPropertyOf :officePhone .
:officePhone2 rdfs:subPropertyOf :officePhone .
:personalPhone rdfs:subPropertyOf :phone .

:instance-member rdf:type :member .

:instance-member   :personalPhone   "value-of-personal-phone" .
:instance-member   :officePhone1   "value-of-office-phone-1" .
:instance-member   :officePhone2   "value-of-office-phone-2" .

Regarding the querying, there are at least two options:

1) The triple store supports reasoning, RDFS would be enough in your example - then your query would be sufficient.

2) You rewrite your query such that the property hierarchy is taken into account using SPARQL 1.1 property paths:

prefix : <http://example.org/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema/>

SELECT ?s ?attr ?data
        values ?p {:officePhone} 
        ?s rdf:type :member .
        ?attr rdfs:subPropertyOf* ?p .
        ?s ?attr ?data .  


| s                | attr          | data                      |
| :instance-member | :officePhone1 | "value-of-office-phone-1" |
| :instance-member | :officePhone2 | "value-of-office-phone-2" |

answered 2 weeks ago Sergio #2

...I got it in a similar way, showing the superproperty, restrincting the domain and including a distinct...

SELECT distinct ?s ?attr_father ?data
    values ?attr_father {:phone} .

    ?s rdf:type :member .
    ?attr rdfs:subPropertyOf* ?attr_father .
    ?attr rdfs:domain :member .
    ?s ?attr ?data .    

In this way, we get,

instance-member   :phone   "value-of-office-phone-1" .
instance-member   :phone   "value-of-office-phone-2" .


comments powered by Disqus