Added the database portion of the code, well, some of it