fix db tables and relationships