Fixed issue with foreign key constraint