The formula of an ionic compound shows the relative numbers of the ions it contains. For example: the formula for sodium chloride is NaCl - it shows that for every Na + ion there is one Cl - ion. the formula for magnesium chloride is MgCl 2 - it shows that for every Mg 2+ ion there are two Cl - ions.