The relationship tree can be queried using the nisapi :http://(UIM
Server Host)/nisapi/relationship/tree?id=(vcenter cs_id).
Spectrum also uses this api and then parses the result to form the hierarchy. Each component knows its immediate parent and children. So, if we want to find the cluster in which a VM is located, then using the relationships first we can find the ESX host where the VM is and then find the clsuter where the ESX is located.
This relationship is stored in UIM database tables.
select * from CM_RELATIONSHIP_CS_CS where target_id = 44
//The source_id of the result will give the cs_id of ESX Host, if target_id is cs_id of a VM
select * from CM_RELATIONSHIP_CI_CS where target_id = 44
// This will give any logical component like resource pool to which this VM belongs.