Ionic compounds dissolve in water by dissociation. Dissociation is the process in which an ionic compound breaks up into its component ions when dissolved in a solvent. The positively charged ions (cations) are attracted to the negatively charged electrode (cathode), while the negatively charged ions (anions) are attracted to the positively charged electrode (anode). This attraction causes the ions to move through the solvent, and the compound is said to be dissociated.
For example, when sodium chloride (NaCl) is dissolved in water, the sodium ions (Na+) are attracted to the cathode, while the chloride ions (Cl-) are attracted to the anode. This causes the NaCl to dissociate into Na+ and Cl- ions, which are then free to move through the water.