Hi Laura
After analyzing the solution, your proposal is so good so far...I created a relationship below:
tag:stardog:designer:locations_example:model:locatedIn a owl:ObjectProperty ;
rdfs:domain tag:stardog:designer:locations_example:model:locations ;
rdfs:label "locatedIn" ;
rdfs:range tag:stardog:designer:locations_example:model:locations .
I also created the triples to link the locations ID with parent locations ID, example:
tag:stardog:1:designer:locations_example:data:locations a tag:stardog:designer:locations_example:model:locations ;
rdfs:label "Europe" ;
tag:stardog:designer:locations_example:model:**locatedIn** tag:stardog:5:designer:locations_example:data:locations .
and for more usability I created an additional rule:
locations_example:childOf owl:inverseOf tag:stardog:designer:locations_example:model:locatedIn .
This approach is usefull for me using property paths with recursive search:
select * { ?x locations_example:childOf+ ?y . }
...but I´m using Virtual Graph (cloud version) and I could't find in the documentation how to define Object Properties. I tried different approach without sucess:
- I tried to create the simple triple:
http://www.stardog.com/locations_example#locatedIn a owl:ObjectProperty .
error message: All triple patterns are expected to have variable subject or embedded triple
- I defined a BIND variable using template:
?locatedIn a owl:ObjectProperty .
...
BIND(template("http://www.stardog.com/locations_example#locatedIn") AS ?locatedIn)
error message: Template must reference one or more variables:
- parsing a string (without template)
BIND("http://www.stardog.com/locations_example#locatedIn" AS ?locatedIn)
error message: Unsupported expression in BIND() for variable ?locatedIn. Found ConstantImpl()
- Not use of ObjectProperty, just DataProperty
?location is mapping all locations from Database with location id, location name and location Parent id
?location locations_example:locatedIn ?locparentId.
It is working but it is not a relationship, it is a Dataproperty so:
- Not possible to use property paths with recursive search
- Not possible to define rule inverseOf
- I tried example in documentation:
<<?location a locations_example:Location >> locations_example:locatedIn ?parentId.
it is working when saving SMS2 but it has 2 inconvenients:
-
Instances are not matching locations_example instances
locations:
locations_example:Location:1
locations_example:Location:2
....
locatedIn:
<< locations_example:Location:1 rdf:type locations_example:Location >>
<< locations_example:Location:2 rdf:type locations_example:Location >>
....
-
Error when using property path
select * { ?a locations_example:locatedIn ?b ; } --> OK
select * { ?a locations_example:locatedIn+ ?b ; } --> KO
error message: Failed to run query: com.complexible.stardog.plan.eval.operator.OperatorException: Uncaught error during query evaluation: InvalidTermReplacement: Cannot transform a service node: SERVICE virtual://hierarchy_VG in= out= {
VirtualGraphMongoDBvirtual://hierarchy_VG [#8] {
RelNode=
LogicalFilter(condition=[AND(IS NOT NULL($0), IS NOT NULL($1))])
UnwoundRel(coll=[organization], key=[[$_id]], projection=[orgid=$LocId, locparentid=$LocParentId])
Query=
{ $match : {$and : [ {"LocId" : {$exists : true, $ne : null}}, {"LocParentId" : {$exists : true, $ne : null}} ]} }
Vars=
?a <- <<TEMPLATE(http://www.stardog.com/locations_example#Location:{orgid/0}) CONSTANT(http://www.w3.org/1999/02/22-rdf-syntax-ns#type) CONSTANT(http://www.stardog.com/locations_example#Location)>>
?b <- TEMPLATE(http://www.stardog.com/locations_example#Location:{locparentid/1})
}
}
could you please provide additional guideance?
Thanks in advance and warm regards