dumb question: diode and relay

Really basic electronic circuit question:
I understand the diode is there to prevent damage to the transistor but I don't understand it's placement in the schematic.

Why is it this instead of this?

In the second picture the diode will block all the current, making the circuit do absolutely nothing.

In the first picture the diode will conduct when there is a voltage across it, created by the discharging coil.

The second 'this' would prevent current from flowing altogether. It would essentially be a do-nothing circuit.

The diode prevents damage to the transistor by limiting the voltage at the collector terminal. Without the diode, when the transistor is turned off (after conducting current through the relay coil), the flow of current does not stop immediately due to the energy stored in the relay's inductance. The current has to find some path to flow from one terminal of the relay coil to the other, and it does so by developing a very high voltage (killing the transistor).

The diode in the first 'this' provides a safe path for this current to flow as the energy in the relay coil decays to 0. It also limits the voltage at the transistor collector terminal to be 0.7V (or so) above the top terminal voltage of the relay.

--
The Ruggeduino: compatible with Arduino UNO, 24V operation, all I/O's fused and protected

When the power is first shut off to an inductor like a relay, the inductor will dump all of the energy stored in it back into the circuit. This energy flows is in the opposite direction (negative becomes positive) of normal for the circuit. In the first example the diode provide a low resistance path for current flowing in the opposite direction from normal.

Thank you for all the info!

Ok in this picture why isn't he using a diode across the reed relay coil? (and why is there no resistor on the red led?)

I'm basically wanting to use raise a pin on the arduino to control a relay coil that will let 12v dc pass though it.

The reed relay coil really should have a diode. He's getting away with it because (a) the reed relay coil can only store a very small amount of energy so when turning it off the voltage doesn't get too high to be of concern, or more likely (b) the built-in ESD diodes of the microcontroller are serving the same function, diverting the coil current to the +5V node on the Arduino.

The red LED really should have a resistor, unless it's a special +5V LED that is designed to be run right off 5V. It's one of those things you can get away with, for a while, until something starts smelling funny and giving off smoke. Then you're not getting away with it anymore.

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons

The reed coil, unlike a conventional relay has no iron core so is of very low inductance. It will still give a negative kick when de-energised but is very much less than that from a metal cored coil. Having said that, it should still have a clamping diode fitted.

Actually the second circuit that the OP referenced has a tiny error, the Diode from collector to the relay coil is shown wrong way round, if it is reversed both circuits will behave identically. In the second circuit (With the diode "Pointing" to the Collector instead of the coil) the diode is open for a negative voltage (When the Magnetic field collapses) but closed for current flowing in the opposite direction... When the transistor is conducting.

Doc