moved db related stuff into the db app. Added doc.