SPARQL - 如何进行连接操作

时间:2018-01-06 11:18:01

标签: sparql rdf semantic-web

我有一个模型,我有3个类:

  1. SR - EMail Entity Attribute Value john.smith@email.com 1 Active 1 john.smith@email.com 1 First_Name John john.smith@email.com 1 Last_Name Smith john.smith@email.com 1 EMail john.smith@email.com
  2. HCVR - <http://data.sample.com/vocab/StudentRecord>
  3. CR - <http://data.sample.com/vocab/HealthCenterVisitRecord>
  4. <http://data.sample.com/vocab/ClassRoom>有一个属性StudentRecord

    classRoom有一个属性HealthCenterVisitRecord

    鉴于特定的studentRecord URI,如何查找属于ClassRoom s的所有StudentRecord

    我试过的查询(查询的初始部分提取属于HealthCenterVisitRecord的学生,但第二部分搞砸了,我知道了):

    ClassRoom

    我尝试了另一个问题:

    SELECT ?hcvr
    WHERE {
      ?sr rdf:type <http://data.sample.com/vocab/StudentRecord>.
      ?sr <http://data.sample.com/vocab/classRoom> <http://data.sample.com/resource/ClassRoom/1156>.
      ?sr <http://data.sample.com/vocab/healthCentreVisitRecord> ?hcvr.
    }
    

1 个答案:

答案 0 :(得分:0)

想出来,这是查询:

SELECT ?hcvr
WHERE {
  ?sr rdf:type <http://data.sample.com/vocab/StudentRecord>.
  ?sr <http://data.sample.com/vocab/classRoom> <http://data.sample.com/resource/ClassRoom/1156>.
  ?hcvr rdf:type <http://data.sample.com/vocab/healthCentreVisitRecord>.
  ?hcvr <http://data.sample.com/vocab/studentRecord> ?sr.
}