Initial support for nested database categories.

This is a pretty major (but needed, because the previous way was a mess)
change in how code accesses a list of databases. This might break stuff
somewhere.
Fix CompletionTable for new database tree.
Fix DuplicateText for new database tree.