Compounds are represented by chemical formulas. A chemical formula shows the elements that make up the compound and the numbers of atoms of each element in the smallest unit of that compound, be it a molecule or formula unit.
Please remember that the ionic compound formed by the combination of ions is electrically neutral. So the ions combine in a number that ensures that the final ionic compound is electrically neutral or there will be a balance in the oppositely charged ions. The number of ions that combine so is represented as subscripts in the formula of the compound.