Dear Stardog Community,
I am using a MySQL-Database with a single table and connect it as a virtual Graph to Stardog. The content of the table is:
id, name, location_id
'1', 'Example 1', 'Location 1'
'2', 'Example 2', 'Location 2'
'3', 'Example 3', 'Location 3'
'4', 'Example 4', 'Location 1'
As you see, the last location_id is the same as the first one.
My Mapping creates an instance of "Example" and one of "Location" and links them with the predicate "atLocation". This is the Mapping:
MAPPING
FROM SQL {
SELECT *
FROMexample
.example
}
TO {
?subject a :Example;
:id ?id ;
:name ?name ;
:atLocation ?location .?location a :Location;
:id ?location_id .} WHERE {
BIND(template("http://api.stardog.com/Example/id={id}") AS ?subject)
BIND(template("http://api.stardog.com/Location/id={location_id}") AS ?location)
}
If I run now the following select statement, it is giving me 10 results:
SELECT ?name ?locId {
GRAPH virtual://example {
?example a :Example ;
:name ?name ;
:atLocation ?location .?location a :Location ; :id ?locId .
}
}
ORDER BY ?name
These are the results
name,locId
Example 1,Location 1
Example 1,Location 1
Example 1,Location 1
Example 1,Location 1
Example 2,Location 2
Example 3,Location 3
Example 4,Location 1
Example 4,Location 1
Example 4,Location 1
Example 4,Location 1
If I copy the data locally using COPY virtual://example TO http://stardog.com/Example and then running the select-statement without referring to the graph, but to the local data, I get the expected results:
name,locId
Example 1,Location 1
Example 2,Location 2
Example 3,Location 3
Example 4,Location 1
Is there something wrong with my mapping? Can you suggest what to do to get the expected results without needing to copy the data locally?
Thank you for your support!
Tim