Update graph data in SQL Update graph data in SQL postgresql postgresql

Update graph data in SQL


Sounds like you need to maintain a transitive closure of the graph for each subject. Look at a paper about how to implement an incremental evaluation system (IES) with SQL, seems to be able to do the trick. The paper has extensive SQL examples for directed acyclic, undirected and arbitrary directed graphs.

It appears that for each of your subject the graph is acyclic, which is fortunately the simplest case.