0

This question was edited to remove an wrong example.

You can see a right way to store and query "subjects for inheritance predicates and inheritance objects" below. Based on UninformedUser advise.

example.ttl

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

uri:Language            rdf:type                rdfs:Class .
uri:English             rdfs:subClassOf         uri:Language .
uri:BritishEnglish      rdfs:subClassOf         uri:English .
uri:Chinese             rdfs:subClassOf         uri:Language .
uri:MandarinChinese     rdfs:subClassOf         uri:Chinese .

uri:know                rdf:type                rdf:Property .
uri:write               rdfs:subPropertyOf      uri:know .
uri:speak               rdfs:subPropertyOf      uri:know .

uri:Alex                uri:speak               uri:English .
uri:John                uri:write               uri:BritishEnglish .
uri:Chen                uri:write               uri:Chinese .
uri:Lin                 uri:speak               uri:MandarinChinese .

sparql

select distinct * { ?p  rdfs:subPropertyOf*    uri:know     . 
                    ?s  ?p                     ?o           . 
                    ?o  rdfs:subClassOf*       uri:Language . }
s   p   o
http://uri/Alex     http://uri/speak    http://uri/English
http://uri/Lin      http://uri/speak    http://uri/MandarinChinese
http://uri/Chen     http://uri/write    http://uri/Chinese
http://uri/John     http://uri/write    http://uri/BritishEnglish
  • I think I don't get it - why is the domain of a property a property? Like `uri:write rdfs:domain uri:know .` - if you are referring to subproperty relation then you should use `rdfs:subPropertyOf` instead of `rdfs:domain` – UninformedUser Dec 08 '22 at 09:51
  • same for `uri:Alex rdfs:domain uri:Person ;` - what do you want to express here? `uri:Alex` is not a property in my opinion, but `rdfs:domain` it's only purpose is to define the domain (which is a class) about a property. It is `PROPERTY rdfs:domain CLASS` – UninformedUser Dec 08 '22 at 09:55
  • also `uri:English rdfs:domain uri:Language .`- that is also weird or simply wrong - why don't you make `English` and instance of `Language` via `rdf:type` property? – UninformedUser Dec 08 '22 at 09:58
  • with "proper" data like `uri:write rdfs:subPropertyOf uri:know . uri:English rdf:type uri:Language .` a query would be `select ?s { ?p rdfs:subPropertyOf* uri:know . ?s ?p ?o . ?o a uri:Language }` – UninformedUser Dec 08 '22 at 10:01
  • Thank you UninformedUser! It works great for me. Is the syntax correct now ? – Nikolay Mashkov Dec 09 '22 at 04:32
  • yep, looks way more standardized. The only other thing one might discuss is whether to use instances for the languages, but I can see that you also have subtypes of e.g. English, so I guess it is fine - and in the end, a matter of taste of course – UninformedUser Dec 12 '22 at 07:07

0 Answers0