Simplify database structure.

No longer use hasParent, instead use check if the parent is 0 to determine if it's a thread.