When a metal atom reacts with a non-metal atom electrons in the outer shell of the metal atom are transferred. Metal atoms lose electrons to become positively charged ions. Non-metal atoms gain electrons to become negatively charged ions. The ions produced by metals in Groups 1 and 2 and by non-metals in Groups 6 and 7 have the electronic structure of a noble gas (Group 0).
An ionic compound is a giant structure of ions. Ionic compounds are held together by strong electrostatic forces of attraction between oppositely charged ions. These forces act in all directions in the lattice, that is in a regular arrangement.
how to work out empirical formulae with 3D diagram

what ions are in the compound, work out what charges the ions will form, balance the charges of the ions so that the overall charge on the compound is zero
A molecule is formed when a group of atoms are joined together by a shared pair of electrons called covalent bonds. Small molecules contain only a few atoms held together by strong covalent bonds. The intermolecular forces are weak, but as the small molecule gets bigger the weak forces between molecules increase.