System and methods of searching documents in a relational database that includes receiving a search query from an application; identifying, via an ancestry table, node identifiers corresponding to the search query; determining, from the corresponding node identifiers, ancestor node identifiers having a depth value greater than zero; and displaying identifiers associated with the ancestor node identifiers to a user. Each entry in the ancestry table includes a node identifier, an ancestor node identifier associated with the node identifier and a depth value corresponding to a distance between the node identifier and the ancestor identifier.