tags:

views:

85

answers:

1

Hi guys, I am just starting SPARQL recently and have got some questions.

  1. When i am querying an endpoint (linked movie database) for actor and director of a given movie title, I will get nothing back if the querying movie has only got one of the requested property ( the movie only has actor or director property, for example this "Batman" film only has actor property http://data.linkedmdb.org/page/film/12583), so is there a way to query for multi-properties and get whatever the available result back even one the the requested property is unavailable?

  2. How can i retrieve all the properties for a given movie title?

Thanks

+2  A: 
  1. You probably want the SPARQL OPTIONAL keyword.
SELECT *
WHERE {
  ?movie a ex:Movie .
  OPTIONAL { ?movie ex:prop1 ?prop1_value }
  OPTIONAL { ?movie ex:prop2 ?prop2_value }
  OPTIONAL { ?movie ex:prop3 ?prop3_value }
}
  1. Something like this:
SELECT ?p ?o
WHERE {
  ex:MyMovie ?p ?o
}

Of course, you'll need to replace all of the URIs above (ex:prop1, ex:MyMovie, etc.) with the actual URIs from the Linked MDB data set.

hope this helps!
Lee