An ionic compound is three-dimensional array of ions, which are present in a definite ionic ratio that is characteristic of the compound.
Since there are no discrete molecules in the lattice of an ionic substance, only an empirical formula can be used to express its composition.
For example, magnesium chloride, which is composed of a collection of Mg2+ and Cl- ions in the ratio of one to two, the empirical formula is MgCl2. There is no molecular formula for magnesium chloride.