Clean, reorganize, and add edict in SQL