Updated Database Code

Updated the database management code.