Added database tables and few functions in controller