For ionic compounds, you will know the proportions in which they combine based solely on charge. Consider the example of sodium sulfate. Sodium ions, since they come from a group I metal, have a charge of +1. Sulfate ions have a charge of -2 (this is something you will probably just have to memorize). For sodium (Na+) and sulfate (SO42-) to form an ionic compound, the compound must have no net charge. For this to happen, sodium sulfate must have the formula Na2SO4. The two sodium ion contribute a +2 charge to balance out the -2 charge of the sulfate.
Now consider aluminum oxide. Aluminum ions have a +3 charge. Oxygen ions have a -2 charge. In order for them to balance, aluminum oxide must have a formula of Al2O3. The two aluminum ions contribute a 2x(+3) = +6 charge and the 3 oxygen ions contribute a 3x(-2) = -6 charge, giving aluminum oxide an overall charge of zero.
This principle can also be used to figure out the charge of unknown ions. Consider a particular form of tin chloride (SnCl2). Since we know that chlorine has a -1 charge (based on its position in the periodic table), the tin must have a +2 charge to balance out the -2 charge contributed by the two chloride ions.