Running mysql(5.5) /linux/ php/python
Got a situation with a test env, where I'm dealing with a number of
spawned processes, that might also spawn processes, so I have a "tree"
where I'm looking to determine when the spawned processes have
completed. To manage this cluster/tree of processes, I'm considering
using a tree kind of DB representation:
The tables would be:
ParentChildTBL
ParentID, int
ChildID int
ItemStatusTBL
Name, varchar
ID, int
Status int
ItemStatusTBL.ID <-- ParentID/ChildID
Tree Graph:
top(1)
|
_________________________________________
|
|
|
itemA(2)
itemB(3)
itemC(4)
|
----------------------------------
| |
|
itemD(5) itemE(6) itemF(7)
pseudo tbl representation
ItemStatusTBL
top, 1, 0
itemA, 2, 0
itemB, 3, 0
itemC, 4, 0
itemD, 5, 0
itemE, 6, 0
itemF, 7, 0
ParentChildTBL
"",1
1,2
1,3
1,4
2,5
2,6
2,7
I've got a test app that spawns off child processes, where each
process then updates the status of the corresponding given item upon
completion. So the status in the itemStatusTBl will change from 0 to
1.
I'm trying to determine how to efficiently be able to determine when
the children of a given top/root node in the parentChildTBL are
complete, ie, have the status set to '1'. (There could be multiple
top level/root nodes, each with their own independent set of children)
I could try to simply look at all the children each time I examine
the tbl, but that might result in a lot of recursive
function/processing in order to get to all the levels...
I've looked at various articles, but not sure which is the best
approach to this kind of issue.
A complete run is determined by: when all children of the top
level/root node != '0'
Is this a self join,left join situation?
A sample query/pointers would be helpful
Thoughts/Thanks