Correcting foreign key constraints