Electrolysis is the separating of an electrolyte (a dissolved or molten ionic compound) by running direct current (e.g. from a battery) through a negative cathode and positive anode to pull the free-moving ions apart to the electrode of opposite charge.
At the cathode positively charged ions (cations) gain electron(s) and at the anode negatively charged ions lose electron(s) to become atoms or molecules of neutral charge. You'll see solid (metal) and/or gas products produced at the electrodes. In electrolysis of aqueous solutions if a metal is more reactive than hydrogen then H2 gas will form at the cathode as the metal displaces hydrogen in water to form metal hydroxide and if the anion is nitrate or sulphate then oxygen will be produced at the anode. In electrolysis of molten compounds there is always formation of a metal at the cathode.
You may write equations for electrolysis showing oxidation (loss of electrons) and reduction (gain of electrons) at each of the electrodes. Both sides of these half equations must have an equal charge to make sure the number of electrons transferred is shown correctly.
When writing half equations remember that electrons are on the left for reduction and on the right for oxidation, and remember to ensure charges and atoms are balanced.