Ions are electrically charged particles. A simple ion is made from a single atom and a molecular ion is made up of several atoms.
No substance is made up of just one type of ion. An ionic compound must contain both positive and negative ions. The positive and negative charges always balance and cancel each other out. We work out the formula of an ionic compound by finding the ratio of positive ions to negative ions that results in the charges balancing.
1 x Na+ = +1
1 x Cl- = -1
Na:Cl = 1:1 so the formula is NaCl.
1 x Mg2+ = +2
1 x O2- = -2
Mg:O = 1:1 so the formula is MgO.
2 x Na+ = +2
1 x O2- = -2
Na:O = 2:1 so the formula is Na2O.
1 x Mg2+ = +2
2 x Cl- = -2
Mg:Cl = 1:2 so the formula is MgCl2.
2 x Na+ = +2
1 x SO42- = -2
Na:SO4 = 2:1 so the formula is Na2SO4.
2 x Al3+ = +6
3 x SO42- = -6
Al:SO4 = 2:3 so the formula is Al2(SO4)3.
Use brackets around a molecular ion when that ion is being multiplied up. In Al2(SO4)3 the ratio of particles Al:S:O = 2:3:12.
Sometimes you can work out the formula of a compound using the ionic model of bonding even when the bonding is not ionic.
Even though water is not made up of hydrogen ions and oxide ions you can still work out its formula by pretending that it is made from these
ions:
2 x H+ = +2
1 x O2- = -2
H:O = 2:1 so the formula is H2O.
In H2O, the H atoms are actually bonded covalently to the O atom.