Implemented basic db functionality