How to write ionic formulae:
Write the metal ion, then the non-metal ion.
Write the charge of each ion after the elements.
Na^1+ Cl^1-
Mg^2+ O^2-
Al^3+ O^2-
Drop and cross the charges without the +/-. Any common factors are cancelled out, and 1s aren't needed.
Na.1 Cl.1 -> NaCl
Mg.2 O.2 -> MgO
Al.2 O.3
When writing with the 'to be memorised' ions, do the same, whilst taking into account the already written formula.