Updated DB structure for tree, along with some queries