Fixed redundant code and added a button and methods to view the complete database and query through it.