update database when model changes and vice versa