I will first try and juxtapose how I imagine your idea of the meaning of subClassOf
(feel free to correct me if my impression is wrong) and its actual meaning, and then go on to explain how you might achieve what you are looking for instead.
For your :combinesWith
property
?color :combinesWith ?coc .
let's assume the following small dataset:
:red :combinesWith :yellow .
:red :combinesWith :purple .
:green :combinesWith :yellow .
:green :combinesWith :white .
:green :combinesWith :black .
:white :combinesWith :silver .
:white :combinesWith :black .
:black :combinesWith :white .
Apparently, you assume that a subproperty of a property X is a property that applies to triples whose predicate is the property X. In concrete terms, in the above dataset, you seem to think you are able to assign a review to each of those combinations, something like (pseudo-code, no valid syntax!):
{ :red :combinesWith :yellow } :hasReview "a combination of warm colors" .
{ :green :combinesWith :yellow } :hasReview "nature, sunflowers" .
{ :black :combinesWith :white } :hasReview "too much contrast for my taste" .
Actually, however, a subproperty Y of a property X can be understood in a way so that for all triples whose predicate is property Y, there is also a triple with the same subject and object whose predicate is X. Or, in a slightly different interpretation, when you're looking for triples whose predicate is X, you will find all triples whose predicate is X and all triples whose predicate is Y. It works in an analogous way to subclasses.
So, for the above dataset, what might be reasonable is to declare a new property :combinesPerfectlyWith
, which is a subproperty of :combinesWith
. Like this, you could change the dataset to something as follows:
:red :combinesWith :yellow .
:red :combinesPerfectlyWith :purple .
:green :combinesPerfectlyWith :yellow .
:green :combinesWith :white .
:green :combinesWith :black .
:white :combinesWith :silver .
:white :combinesWith :black .
:black :combinesWith :white .
You are not losing any information here, you are just further specifying some information.
Now, back to what you actually seem to want to do - assign one or more reviews with color combinations.
To do so, the actual review (or at least an indicator of its presence?) will be the object of your review-related triples, and you will have to have something that can be the subject. That something needs to be another IRI or blank node, one that represents the color combination.
Therefore, you may want to redefine your ontology in a way that there is a :ColorCombination
type with properties like :color
and :hasReview
. An excerpt of the dataset might then look as follows:
_:cc1 a :ColorCombination ;
:color :red ;
:color :purple .
_:cc2 a :ColorCombination ;
:color :red ;
:color :yellow ;
:hasReview "a combination of warm colors" .
...
Now, in your SPARQL query, you can fetch the values with some straightforward triple patterns. I am not entirely sure what your query is intended to do, given that your nested SELECT
query exports only the variable ?coc
, which is not connected to your restrictions in the outer query.