I consulted a friend, and heres what he said.
To answer your question about how we determine the chemical formula for a compound, here's how it works. There are a variety of techniques we can use to dermine what elements are present in a particular chemical. These techniques include: gas-chromotography/mass-spectrometery(GCMS), nuclear magnetic resonance (NMR), infrared spectrosocopy (IR) and a few other chromatographic methods. These techniques can identify what elements are present and what percentage of the compound it makes up. I don't know how much detail you are looking for here but I can explain this further if you would like. I would recommend that you go to google and look up the information on GCMS, NMR and IR and that will help you understand how each one of these work.