Adding db stuff

Added some db functionality.