Seems like two very separate questions here. One on syntax and one on modeling.
For the syntax problem I'd suggest looking at Turtle - Terse RDF Triple Language. Turtle specifies triples, which requires three entities in the specification of a triple. The .
specifies the end of a triple. As a shortcut, a ;
means the current subject is carried over to the next triple specification - hence only the predicate and object need to be specified. A ,
means the subject and object are carried over to the next triple. Therefore,
<#spiderman> foaf:name "Spiderman", "Человек-паук"@ru .
Specifies two triples:
<#spiderman> foaf:name "Spiderman" .
<#spiderman> foaf:name "Человек-паук"@ru .
One the modeling question, to specify the different nationalizations of Leipzig at different epochs of time, specify a property, such as isMemberOfCountry
that has properties of fromDate
and toDate
. Each instance of country membership would then be populated:
@prefix ex: <http://example.org/geoex/>
ex:Leipzig
ex:isMemberOfCountry [
ex:country ex:DDR ;
ex:fromDate 1945 ;
ex:toDate 1990 ;
] ;
ex:isMemberOfCountry [
ex:country ex:Germany ;
ex:fromDate 1990 ;
] .
Bnodes are used ensure unique names across the dataset for an object whose name may not matter (if it does, then specify an object a use in place of the bnode). Then to query the current country, use:
SELECT ?country
WHERE {
ex:Leipzig ex:isMemberOfCountry ?member .
?member ex:country ?country .
FILTER NOT EXISTS {
?member ex:toDate ?d
}
}
And to find the membership during a specific year, use the following:
SELECT ?country
WHERE {
BIND("1991"^^xsd:integer AS ?date) #placeholder - ?date should be passed into the query
ex:Leipzig ex:isMemberOfCountry ?member .
?member ex:country ?country .
?member ex:fromDate ?fdate .
OPTIONAL {?member ex:toDate ?td}
BIND(IF(bound(?td), ?td, year(now())) AS ?edate)
FILTER (?date >= ?fdate && ?date <= ?edate)
}
Note that binding ?date
to 1990 will result in two results, which is correct given that years are used instead of dates in this example model.