Mostly we give empirical formulas for ionic compounds which are in the crystalline form. Divide the molecular weight of the molecular formula by the the molecular weight of the empirical formula to find the ratio between the two. The molecular formula shows the exact number of different types of atoms present in a molecule of a compound.
For instance we cannot say the exact number of Na and Cl in a NaCl crystal.
In the same manner compounds can have the same molecular formula. Thus sulfur monoxide and disulfur dioxide both compounds of sulphur and oxygen have the same empirical formula. The empirical formula simply states the ratios of the elements that make up the molecule while molecular formulas specify the amounts of each element exactly not just giving the ratio. Compare molecular formula structural formula.