There is a table distances(city1, city2, dist)
that list couple of cities and distances between them. The deal is, that from this information we can get more distances, like there is in table distances
dist A -> B and dist B -> C so we can get A -> C that is not in the distances
.
Task is to generate table distances_tr(city1, city2, dist)
with transitive closure of the 1st table, that will include (A, C, dist(A,C))
.
How can I achive that using PROCEDURE
and simple SQL SELECT, INSERT, UPDATE
commands? I know it can be done recursively, but Professor told us to do it both ways.