The formula of an ionic compound represents the simplest whole number ratio of ions present.
The net charge on an ionic compound is zero, so the sum of the positive charges equals the sum of the negative charges.
A subscript number written to the right of an element's symbol tells us how many of those ions are present in the formula. for example: potassium sulfide has the formula K2S, 2 potassium ions (K+) and 1 sulfide ion (S2-) are present. If no number is given, then only one of that ion is present. for example: sodium hydride has the formula NaH, 1 sodium ion (Na+) and 1 hydride ion (H+) are present.
If more than one polyatomic ion (ion having more that one element in its formula) is present, round brackets enclose the formula of the polyatomic ion and a subscript number written to the right of the final bracket tells us how many of that polyatomic ion are present in the formula. for example, the nitrate ion is a polyatomic ion, NO3-, it is an ion containing nitrogen and oxygen atoms. Calcium nitrate has the formula Ca(NO3)2 and it contains 1 calcium ion (Ca2+) and 2 nitrate ions (NO3-).