A chemical formula is the way in which we communicate exactly what the composition of a given substance is. Every element that is part of the substance must be listed in the chemical formula. And not only is it listed, but it is also listed in whole number amounts so that we know the exact elemental make up of that substance just by interpreting (disecting) the chemical formula. The players in the formula are simple, they are the elements of the periodic table. Each and every element known is listed and is either represented as a single capital letter or as two letters with the first capitalized and the second lowercase. Here are some examples:
Some One-Letter Elements
Some Two-Letter Elements
The amount of each element is conveyed via a numeric subscript in the formula. The "number system" here is the number of atoms of that element to make one full formula. So the subscripts are always counting numbers - whole numbers. For example, water is a substance that has molecules made out of two hydrogen atoms and one oxygen atom. Therefore, the chemical formula for water is H2O. A bigger example would be ethanol which has the formula C2H6O. Note that we do not subscript ones because that is always assumed if you list the element in the formula. Once you have that figured out, you can use those counts to calculate the formula weight or molar mass of the substance.
2 carbons at 12.011 = 24.022
6 hydrogens at 1.008 = 6.048
1 oxygen at 16.00 = 16.00
The grand total of those parts equals 46.070. Therefore the molar mass of ethanol is 46.070 g/mol. Notice because I said "molar" mass the units are in grams per mole or g/mol. That is the typical unit that we use in chemistry because we can see and touch and weigh out gram amounts like this. However, some folks prefer to think amount that number as the mass of just one single molecule. To do this in grams, we would divide the molar mass by Avogadro's number and get the answer in grams which would be incredibly small (7.65×10-23 g) OR we could just change units to be in atomic mass units or amu's. The mass of one molecule of ethanol is 46.070 amu or even better if you want to follow the newer SI standard, 40.070 u. One "u" is a unified atomic mass unit and can also be switched out with the unit "dalton" which is abbreviated as Da. Unless told otherwise, you should always go with the g/mol unit for formula weights.
The empirical formula for a substance only has to show the correct RATIO of elements that are contained in the formula. The molecular formula has to show the actual correct number of atoms of each element in the overall molecule. An example is the best way to show the difference.
Example: Consider the 3 substances formaldehyde, acetic acid, and glucose. All three have the same empirical formula of CH2O. But they all three have different molecular formulas.
All of these substances have a whole number ratio of the elements of C, H, and O of 1:2:1. The molecular formula for acetic acid is 2× that of the empirical formula and glucose is 6× that of the empirical. This also means that the percent composition of all three of these substances is identical - specifically they are all 30.0% C, 6.7% H, and 53.3% O by mass. But the molecular weights are all different at 30.027, 60.054, and 180.162. You should be able to convert percent composition into an empirical formula and vice versa. Then, if you are given a bit more information, you can convert the empirical formula into an actual molecular formula.
A molecular formula is great for knowing the pieces (atoms) of the overall molecular unit - but it doesn't necessarily tell you how those pieces are assembled. A great example is the molecular formula for ethanol given earlier, C2H6O, with a molecular weight of 46.1 g/mol (I rounded). Well guess what? That is the exact same molecular formula and weight for another compound called dimethyl ether. The way they differ is the way in which the atoms are put together - the structure. How do we convey structure in a formula? Well, there are ways - but you'll need a bit more experience with bonding and structure to "see" it. I'll at least show you the line structures of the two substances below.
Note the different arrangement of the atoms and bonds. These substances are very different in their physical and chemical properties as well. What is shown is a structural formula which means that the way the atoms are connected is shown. Those two formulas can even be "shown" inline by knowing a bit how we show connectivity inline. We basically show inline connectivity by doing it in sections until the molecule is complete. Ethanol's structural formula inline is CH3CH2OH. Notice the way we broke up the structure into smaller units. The dimethyl ether inline formula would be CH3OCH3.
Structural isomers are compounds with the same molecular formula, but have different structures. This is just like ethanol and dimethyl ether. Structure isomers have the same number and types of atoms in them but they are connected to each other in different ways.
There are often parts of a formula that are repeated in the overall formula. We show multiplicity by enclosing the repeat unit in parentheses and then subscripting for the count. This is used often in ionic compound formulas with polyatomic ions. An example would be iron(II) phosphate which has the formula of Fe3(PO4)2. Notice how the phosphate part of that formula is in parentheses and shows a 2× repeat. This is especially useful when you repeat a lot of times like with long chain alkanes. Decane is a straight-chain 10-carbon hydrocarbon. But instead of showing every carbon-hydrogen unit in the chain we show it as CH3(CH2)8CH3. This saves space and conveys the correct structure as well.
Sometimes water will bind to a salt and make a hydrate. The number of waters will vary. If just one water binds it is called a monohydrate. An example of this is Ca(H2PO4)2·H2O which is called calcium dihydrogen phosphate monohydrate. Copper(II) sulfate makes a common hydrate with five waters (pentahydrate) which is CuSO4·5H2O. Just notice how we show the waters separately but "joined" with that dot. The dot is not a multiplication sign like in math - it is just a joiner that tells us the molecule is strongly adsorbed to the main molecule or salt.