database handling for view and update