Finding Related Topics

Top  Previous  Next

The simplest way to find all topics related to another topic is to use a single predicate where the subject is the topic to start from, the predicate is a role type or arc type and the object is either a topic that plays the type of role specified by the predicate in an association with the topic specified by the subject, or a topic that is at the end of an arc of the type specified by the predicate.

 

For example, if our topic map has an employment association defined by the association type http://psi.networkedplanet.com/types/employment with role types http://psi.networkedplanet.com/types/employee and http://psi.networkedplanet.com/types/employer then the following queries find all employees of the company identified by the subject identifier http://example.com/about:

SELECT ?employee WHERE { <http://example.com/about> <http://psi.networkedplanet.com/types/employee> ?employee }

 

If our topic map has an arc type http://xmlns.org/foaf/0.1/knows then the following queries will find all the people that the person identified by the subject identifier http://example.com/people/bob knows.

 

SELECT ?friend WHERE { <http://example.com/people/bob> <http://xmlns.org/foaf/0.1/knows> ?friend }

 

With this simple type of traversal across associations it is not possible to filter based on the type of role played by the starting topic or the association type or scope. For these more advanced query scenarios you must traverse the full topic map structure.