2011-09-26 2 views
1

hasParent realtionship을 가진 패밀리가있는이 RDF 데이터 세트가 있습니다. 나는 다음과 같은 쿼리가있는 모든 형제 자매 쌍을 검색하려면 :SPARQL에서 하프 브러더/자매를 얻는 방법?

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

, 어떻게 모든 halfbrother/자매 쌍을받을 수 있나요? 이것은 한 명의 부모 만이 공통 인 형제 자매를 의미합니다.

편집 : 어쩌면 중요한 데이터 집합은 또한 marriedWith 관계

답변

1

당신을 위해이 일을합니까 포함?

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

감사합니다. – Javaaaa