PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX my: <http://www.ex.com#>
SELECT distinct ?person ?nationality
WHERE{
?person rdf:type ?p.
?person my:Nationality ?nationality.
filter (?nationality = "Some nationality")
}
I have created an ontology in Protege which describes a music production company. I have trouble understanding the SPARQL queries and the way they work.
Some explanations
?person
: variable in which I want to output people. They are individuals in Protege
?nationality
a variable in which I want to output nationalities. They are
data properties in Protege
Nationality
: data property which contains nationalities as strings and every person has one
my
: prefix I created
How does this work ?person rdf:type ?p
and how does it select the right type? Does it work automatically? I don't feel like I have set the ?person
variable as a type Person variable (which is a class I have created and it describes a person as an entity), even though it outputs exactly the outcome I need.