update the model and database