没有 FROM 关键字的 Sparql
很高兴有人能澄清。
我总是读到 SQL 和 SPARQL 非常相似。 然而,很多时候我看到 sparql 查询没有 FROM 关键字。 您会假设您必须在数据库中的某个位置查询数据源“FROM” 就像 SQL 的行为方式一样。
示例
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name
WHERE
{
?person foaf:name ?name .
}
它如何知道去哪里寻找?就像在 SQL 中一样,查看 Database1 - table1
干杯
Glad if someone can clarify.
I always read that SQL and SPARQL are very similar.
However, a lot of times i have seen sparql query without the FROM keyword.
You would assume that you have to query the datasource 'FROM' somewhere in the database
like how SQL behaves.
Example
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name
WHERE
{
?person foaf:name ?name .
}
How does it know where to look for? Like in SQL, look in Database1 - table1
Cheers
SPARQL 查询针对 RDF 数据集 执行,该数据集由两部分组成:
您可以使用可选的
FROM
或FROM NAMED
子句指定要查询的图。查看指定 RDF 数据集。如果省略这些子句,则查询将在默认图上执行。图和 RDF 数据集存储取决于实现。例如,使用 Jena ARQ,您可以使用
QueryExecutionFactory
并且可以初始化它有两种方式:Model
,它成为通过Dataset
,它可以包含单个默认图和多个命名图Jena ARQ 的代码示例为可用此处。其他实现可能有所不同。
SPARQL queries are execute against an RDF dataset, which has two parts:
You can specify the graph to query using the optional
FROM
orFROM NAMED
clauses. Have a look at Specifying RDF Datasets. If you omit those clauses, then the query is executed on the default graph.Graphs and RDF dataset storage is implementation dependent. For example, using Jena ARQ you use a
QueryExecutionFactory
and you can initialize it in two ways:Model
, which becomes the default graph on which queries are executedDataset
, which can contain a single default graph and several named graphsCode Examples for Jena ARQ are available here. Other implementation may be different.