Updating tables in a database