SPARQL - 如何进行连接操作
SPARQL - how to do a join operation
我有一个模型,我有 3 个 类:
- SR -
<http://data.sample.com/vocab/StudentRecord>
- HCVR -
<http://data.sample.com/vocab/HealthCenterVisitRecord>
- CR -
<http://data.sample.com/vocab/ClassRoom>
StudentRecord
有一个 属性 classRoom
.
HealthCenterVisitRecord
有一个 属性 studentRecord
.
给定一个特定的 ClassRoom
URI,我如何找到所有 StudentRecord
s,它们是 HealthCenterVisitRecord
s 的属性。
我试过的查询(查询的初始部分获取属于 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.
}
我试过的另一个查询:
SELECT DISTINCT ?sr WHERE {
{
?sr rdf:type <http://data.sample.com/vocab/StudentRecord>.
?sr <http://data.latize.com/vocab/classRoom> <http://data.latize.com/resource/ClassRoom/1156>.
}
UNION
{
?hcvr rdf:type <http://data.sample.com/vocab/HealthCentreVisitRecord>.
?hcvr <http://data.sample.com/vocab/studentRecord> ?sr.
}
}
LIMIT 1000
想通了,这里是查询:
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.
}
我有一个模型,我有 3 个 类:
- SR -
<http://data.sample.com/vocab/StudentRecord>
- HCVR -
<http://data.sample.com/vocab/HealthCenterVisitRecord>
- CR -
<http://data.sample.com/vocab/ClassRoom>
StudentRecord
有一个 属性 classRoom
.
HealthCenterVisitRecord
有一个 属性 studentRecord
.
给定一个特定的 ClassRoom
URI,我如何找到所有 StudentRecord
s,它们是 HealthCenterVisitRecord
s 的属性。
我试过的查询(查询的初始部分获取属于 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.
}
我试过的另一个查询:
SELECT DISTINCT ?sr WHERE {
{
?sr rdf:type <http://data.sample.com/vocab/StudentRecord>.
?sr <http://data.latize.com/vocab/classRoom> <http://data.latize.com/resource/ClassRoom/1156>.
}
UNION
{
?hcvr rdf:type <http://data.sample.com/vocab/HealthCentreVisitRecord>.
?hcvr <http://data.sample.com/vocab/studentRecord> ?sr.
}
}
LIMIT 1000
想通了,这里是查询:
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.
}