sparql - 如何查询多个实体?
sparql - how to query through multiple entities?
我有一个 rdf-schema 和 turtle 语法中的三元组(摘录):
@prefix dbr: <http://dbpedia.org/resource/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#own, TODO change it
@prefix japany: <http://vschuberth.bplaced.net/rdfschema.ttl#> .
japany:import a rdfs:Class.
japany:food a rdfs:Class.
japany:radioactiveIngredients a rdfs:Class.
japany:imports a rdf:Property;
rdfs:range dbr:PopulatedPlace;
rdfs:domain japany:import.
japany:exports a rdf:Property;
rdfs:range dbr:PopulatedPlace;
rdfs:domain japany:import.
japany:importQuantity a rdf:Property;
rdfs:range xsd:integer;
rdfs:domain japany:import.
japany:importValue a rdf:Property;
rdfs:range xsd:integer;
rdfs:domain japany:import.
japany:year a rdf:Property;
rdfs:range xsd:gYear;
rdfs:domain japany:import.
japany:isPartOf a rdf:Property;
rdfs:range japany:import;
rdfs:domain japany:food.
japany:nameOfIng a rdf:Property;
rdfs:range rdf:Class;
rdfs:domain japany:radioactiveIngredients.
japany:amount a rdf:Property;
rdfs:range japany:bqkg;
rdfs:domain japany:radioactiveIngredients.
japany:nameOfFood a rdf:Property;
rdfs:range rdf:Class;
rdfs:domain japany:food.
japany:dateOfSampling a rdf:Property;
rdfs:range xsd:date;
rdfs:domain japany:radioactiveIngredients.
japany:isIn a rdf:Property;
rdfs:range xsd:food;
rdfs:domain japany:radioactiveIngredients.
<#Import_of_Olivenöl>
japany:imports dbr:Germany;
japany:exports dbr:Japan;
japany:importQuantity 0;
japany:importValue 36;
japany:year "2011"^^xsd:gYear.
<#Olivenöl_Class>
japany:isPartOf <#Import_of_Olivenöl>.
<#Iodine131_in_Olivenöl>
japany:nameOfIng "Iodine131";
japany:amount "< 2,3";
japany:nameOfFood "Olivenöl";
japany:dateOfSampling "15.04.2011"^^xsd:date;
japany:isIn <#Import_of_Olivenöl>.
<#Cesium134_in_Olivenöl>
japany:nameOfIng "Caesium134";
japany:amount "< 1,54";
japany:nameOfFood "Olivenöl";
japany:dateOfSampling "15.04.2011"^^xsd:date;
japany:isIn <#Import_of_Olivenöl>.
<#Cesium137_in_Olivenöl>
japany:nameOfIng "Caesium137";
japany:amount "< 1,95";
japany:nameOfFood "Olivenöl";
japany:dateOfSampling "15.04.2011"^^xsd:date;
japany:isIn <#Import_of_Olivenöl>.
我对如何查询所有这些实体感到困惑。它们是相互关联的。例如:我想写一个/多个查询来获取每年每种食物的进口价值和进口数量,并列出每种放射性成分的含量。
这个查询会给我不正确的数据:
PREFIX japany: <http://vschuberth.bplaced.net/rdfschema.ttl#>
SELECT ?importValue ?importQuantity ?name ?year
WHERE {
?trade japany:importValue ?importValue;
japany:year ?year;
japany:importQuantity ?importQuantity.
?food japany:nameOfFood ?name.
}
ORDER BY ?importQuantity
有人可以帮忙吗?
问题是 ?food
和 japany:import
在您的查询中没有链接。
这是一个有效的查询:
PREFIX japany: <http://vschuberth.bplaced.net/rdfschema.ttl#>
SELECT ?importValue ?importQuantity ?name ?year
WHERE {
?food japany:isPartOf ?import .
?import japany:importValue ?importValue ;
japany:importQuantity ?importQuantity ;
japany:year ?year .
?food japany:nameOfFood ?name.
}
ORDER BY ?importQuantity
但这令人毛骨悚然:
japany:nameOfFood a rdf:Property;
rdfs:range rdf:Class.
为什么不将其创建为 DatatypeProperty
并因此存储 Literal
?
我有一个 rdf-schema 和 turtle 语法中的三元组(摘录):
@prefix dbr: <http://dbpedia.org/resource/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#own, TODO change it
@prefix japany: <http://vschuberth.bplaced.net/rdfschema.ttl#> .
japany:import a rdfs:Class.
japany:food a rdfs:Class.
japany:radioactiveIngredients a rdfs:Class.
japany:imports a rdf:Property;
rdfs:range dbr:PopulatedPlace;
rdfs:domain japany:import.
japany:exports a rdf:Property;
rdfs:range dbr:PopulatedPlace;
rdfs:domain japany:import.
japany:importQuantity a rdf:Property;
rdfs:range xsd:integer;
rdfs:domain japany:import.
japany:importValue a rdf:Property;
rdfs:range xsd:integer;
rdfs:domain japany:import.
japany:year a rdf:Property;
rdfs:range xsd:gYear;
rdfs:domain japany:import.
japany:isPartOf a rdf:Property;
rdfs:range japany:import;
rdfs:domain japany:food.
japany:nameOfIng a rdf:Property;
rdfs:range rdf:Class;
rdfs:domain japany:radioactiveIngredients.
japany:amount a rdf:Property;
rdfs:range japany:bqkg;
rdfs:domain japany:radioactiveIngredients.
japany:nameOfFood a rdf:Property;
rdfs:range rdf:Class;
rdfs:domain japany:food.
japany:dateOfSampling a rdf:Property;
rdfs:range xsd:date;
rdfs:domain japany:radioactiveIngredients.
japany:isIn a rdf:Property;
rdfs:range xsd:food;
rdfs:domain japany:radioactiveIngredients.
<#Import_of_Olivenöl>
japany:imports dbr:Germany;
japany:exports dbr:Japan;
japany:importQuantity 0;
japany:importValue 36;
japany:year "2011"^^xsd:gYear.
<#Olivenöl_Class>
japany:isPartOf <#Import_of_Olivenöl>.
<#Iodine131_in_Olivenöl>
japany:nameOfIng "Iodine131";
japany:amount "< 2,3";
japany:nameOfFood "Olivenöl";
japany:dateOfSampling "15.04.2011"^^xsd:date;
japany:isIn <#Import_of_Olivenöl>.
<#Cesium134_in_Olivenöl>
japany:nameOfIng "Caesium134";
japany:amount "< 1,54";
japany:nameOfFood "Olivenöl";
japany:dateOfSampling "15.04.2011"^^xsd:date;
japany:isIn <#Import_of_Olivenöl>.
<#Cesium137_in_Olivenöl>
japany:nameOfIng "Caesium137";
japany:amount "< 1,95";
japany:nameOfFood "Olivenöl";
japany:dateOfSampling "15.04.2011"^^xsd:date;
japany:isIn <#Import_of_Olivenöl>.
我对如何查询所有这些实体感到困惑。它们是相互关联的。例如:我想写一个/多个查询来获取每年每种食物的进口价值和进口数量,并列出每种放射性成分的含量。
这个查询会给我不正确的数据:
PREFIX japany: <http://vschuberth.bplaced.net/rdfschema.ttl#>
SELECT ?importValue ?importQuantity ?name ?year
WHERE {
?trade japany:importValue ?importValue;
japany:year ?year;
japany:importQuantity ?importQuantity.
?food japany:nameOfFood ?name.
}
ORDER BY ?importQuantity
有人可以帮忙吗?
问题是 ?food
和 japany:import
在您的查询中没有链接。
这是一个有效的查询:
PREFIX japany: <http://vschuberth.bplaced.net/rdfschema.ttl#>
SELECT ?importValue ?importQuantity ?name ?year
WHERE {
?food japany:isPartOf ?import .
?import japany:importValue ?importValue ;
japany:importQuantity ?importQuantity ;
japany:year ?year .
?food japany:nameOfFood ?name.
}
ORDER BY ?importQuantity
但这令人毛骨悚然:
japany:nameOfFood a rdf:Property;
rdfs:range rdf:Class.
为什么不将其创建为 DatatypeProperty
并因此存储 Literal
?