Controlling a relay

If you want to know about how a transistor works try the first part of this article. After that it gets a bit heavy:-
http://www.thebox.myzen.co.uk/Hardware/Transistor_Tester.html

Then as an encore look at the relay at the end of this:-
http://www.thebox.myzen.co.uk/Tutorial/Power_Supplies.html
it is basically the same as the schematic linked before but there are some words of explanation with it.