Proper resistor for simple circuit
A diode that requires 5V is presumably a Zener diode.  Zener diodes are designed to maintain a reasonably constant voltage as the current through them varies.  They are usually used to provide a constant voltage to power other circuit elements. It is necessary to  have a resistor in series with a Zener diode to control the current.  Normally a Zener diode is rated to have a certain current through it to be able to maintain a constant voltage.  You need to know this current plus the current to be drawn into the following circuit to select the required resistor.  For example, if the Zener diode needs 10 ma to work properly, and the following circuit requires 20 ma, then the supply feeding the diode must provide 30 ma. In your example, with a 9V battery as the source, the resistor must drop 9V-5V or 4V while conducting 30 ma.  Thus the value of the resistor should be 4/0.03 or 133 ohms.