开发者

How to get halfbrothers/sisters in SPARQL?

开发者 https://www.devze.com 2023-04-08 16:53 出处:网络
I have this RDF dataset with a family that has the hasParent realtionship. To search for all brother and sisters pairs I have the following query:

I have this RDF dataset with a family that has the hasParent realtionship. To search for all brother and sisters pairs I have the following query:

SELECT DISTINCT ?name1 ?name2
WHERE {
    ?subject1 oranje:hasParent ?object .
    ?subject2 oranje:hasParent ?object .
    ?subject1 rdfs:label ?name1 .
    ?subject2 rdfs:label ?name2 .
    FILTER (?subject1 != ?subject2)
}

However, How do I get all the halfbrother/sisters pair? This means: brothers and sisters that have only one parent in common.

Edit: maybe important, the d开发者_如何学Goataset also contains the marriedWith relationship


Does this work for you?

SELECT DISTINCT ?name1 ?name2
WHERE {
   ?child1 oranje:hasParent ?parent , ?otherparent1 .
   ?child2 oranje:hasParent ?parent , ?otherparent2 .
   ?child1 rdfs:label ?name1 .
   ?child2 rdfs:label ?name2 .
   FILTER (?child1 != ?child2)
   FILTER (?otherparent1 != ?parent)
   FILTER (?otherparent2 != ?parent)
   FILTER (?otherparent1 != ?otherparent2)
}
0

精彩评论

暂无评论...
验证码 换一张
取 消