refactor ER diagram and database schema