Updating foreign keys