added database schema and fixed a bug in setting the associations for the models