The SPARQL specification mentions that the FROM
clause can be used to specify a dataset.
A SPARQL query may specify the dataset to be used for matching by using the
FROM
clause and theFROM NAMED
clause to describe the RDF dataset.
What is a "dataset" in the context of SPARQL? I'm very familiar with databases in general, and I understand in principle that a query for data phrased in a language such as SQL is then executed against a dataset to resolve some subset of that dataset.
I'm trying to understand the following query:
prefix cpmeta: <...some_domain>
select distinct
?uri
?label
?stationId
from <...some_domain>
from <...some_domain>
from <...some_domain>
from <...some_domain>
from named <...some_domain>
where {
{ ?uri rdfs:label ?label }
UNION
{ ?uri cpmeta:hasName ?label }
UNION
{
graph <...some_domain> {
?uri a cpmeta:Station .
?uri cpmeta:hasName ?label .
}
}
?uri cpmeta:hasStationId ?stationId
}
limit 100
So from the specification documentation I understand in principle that
- There are 4 datasets specified, and (I think)
- One 'RDF dataset' is defined
However. The query actually executes (but with slightly different results) if I leave out the FROM
and FROM NAMED
clauses:
prefix cpmeta: <...some_domain>
select distinct
?uri
?label
?stationId
where {
{ ?uri rdfs:label ?label }
UNION
{ ?uri cpmeta:hasName ?label }
UNION
{
graph <...some_domain> {
?uri a cpmeta:Station .
?uri cpmeta:hasName ?label .
}
}
?uri cpmeta:hasStationId ?stationId
}
limit 100
So clearly??? there is already a dataset specified. Is that via the prefix
?
Questions:
- Why is an
RDF dataset
identified differently to a regular dataset (FROM
vsFROM NAMED
) - The URI for the prefix is actually reused in a
FROM
statement. What is the difference between a prefix and aFROM
clause?
This question - Specifying dataset within a SPARQL query - shows how to specify a dataset, but doesn't explain what that means in the context of a SPARQL query and in the context of however that SPARQL query is resolved to actual data.
This question - FROM clause in SPARQL queries - mentions that a SPARQL query without a FROM clause is executed against a default dataset. But then why would omitting all datasets still result in data returned by the query?