One is sodium chloride; the other is either butane or methyl propane (these are structural isomers). Sodium chloride is an ionic compound; alkanes are covalent compounds.
These are just two examples of types of compounds. There are other types. Chemical bonding and chemical structure should be considered together, but here let's concentrate on chemical formulae.
For a covalent compound, the empirical formula gives the simplest whole-number ratio of atoms that make up a molecule of that compound.
C4H10 is a molecular formula, giving the actual ratio of each type of atom in a molecule. C2H5 is the empirical formula. In a balanced equation for a chemical reaction, the molecular formula is normally used. For example:
C4H10(g) + 6ŻO2(g) ® 4CO2(g) + 5H2O(l)
Structural formulae show how the atoms in a molecule are bonded together. Butane and methylpropane consist of discrete molecules each of which is a separate entity; they have a 'simple molecular' structure.
Now back to sodium chloride. NaCl is, in fact, an empirical formula. This is because ionic compounds have giant ionic lattice structures: in sodium chloride, each Na+ is surrounded by 6 Cl- ions and each Cl- by 6 Na+ ions. The Na+ and Cl- ions exist in a simple whole-number ratio of 1:1.
However, when we represent sodium chloride in a balanced chemical equation, of course, the formula NaCl is used. For example:
NaCl(aq) + AgNO3(aq) ® AgCl(s) + NaNO3(aq)
For an ionic compound, if you know the formulae of the ions present it is easy to obtain its formula. For example, aluminium oxide consists of Al3+ ions and O2- ions. For the total charges to balance and equal zero you would require two Al3+ and three O2- ions. Its formula is Al2O3. Sometimes, though less often now, the term valency is used. Here aluminium has a valency of 3 and oxygen a valency of 2.
Place an Al3+ ion
Balancing the opposite charges...
For a covalent compound, particularly those with small molecular structures, you might be able to obtain a chemical formula by making use of simple dot-cross diagrams. Normally, you should remember many of the common examples. This also applies to several elements which also exist as simple molecules under normal conditions, for example, H2(g), O2(g), O3(g), N2(g), Cl2(g), Br2(l), I2(s). The noble gases are all monatomic. Sulphur consists of S8 molecules and phosphorus of P4 molecules, but in chemical equations they are normally represented as S and P respectively.