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

1 Answer 1

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 .
}
Sign up to request clarification or add additional context in comments.

2 Comments

How do i limit the number of books returned using DESCRIBE. Say LIMIT 10
You add LIMIT 10. For more control, use a sub-SELECT inside the pattern part.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.