queries for transitive closure