The electrolysis process takes place when, applying a difference of electric potential to an acqueos solution of acids, bases, salts, a circulation of D.C. current strictly related to mass transfer phenomena is created in the solution itself. 
The driving means of the electric charges are not the molecules neither of the solvent nor of the dissolved compound, but only parts of themselves. 
Acid, bases and salts, when dissolved in definite solvents, have their molecules divided in two parts and, after the appling of D.C. current, one part (anion) migrates and deposits itself at the positive electric polarity or anode, whilst the other (cation) at the negative electric polarity or cathode. These parts of the molecule can be atoms or groups of atoms. 
This is the separation that occurs, for instance, to the atoms of Chlorine and Sodium or Chlorine and Potassium when dissolved into their conductive electrolytic solution in which they are contained in ionic form : a consequence of what described before is, for example, the Sodium Hypochlorite production in the electrochemical industry.