0

The rdf schema is entailed in question

sparql DESCRIBE query to get data about linked objects

The following query executes in a fraction of a second.

DESCRIBE ?book
where
{
 ?book a schema:Book ;

}

The describe query however doesn't give me author details. It returns only properties belonging to Book itself.

So i replaced the above query with the one entailed below.

CONSTRUCT 
{
?book a schema:Book ;
schema:bookName ?bookName ;
schema:bookId ?bookId ;
schema:authoredBy ?author .
?author a schema:Person ;
schema:personName ?personName .

} 
where 
{
 ?book a schema:Book ;
}

However the above sparql query takes 4 seconds for execution.

 Is there way to optimize the sparql CONSTRUCT 
 OR
 should we be using SELECT always instead of CONSTRUCT
Community
  • 1
  • 1
Anubhav
  • 87
  • 3

1 Answers1

1

Your CONSTRUCT query has some unbound variables so will not give you the information that you say you want. Try:

CONSTRUCT WHERE
{
 ?book a schema:Book ;
    schema:bookName ?bookName ;
    schema:bookId ?bookId ;
    schema:authoredBy ?author .
    ?author a schema:Person ;
    schema:personName ?personName .
}

If you are getting triples for ?author, then the system is not acting in a standard way.

As for speed, it will depend on which system you are using.

You could also try describing two related things:

DESCRIBE ?book ?author {
   ?book a schema:Book ;
        schema:authoredBy ?author .
}
AndyS
  • 16,345
  • 17
  • 21