Updating tables with foreign key constraints