restructured db library and implemented querybuilders