Controlling a relay

hi,

this diagram is great, thanks. i think it's shown me that i was trying to do this the wrong way. i was assuming that you could control the relay directly as if it were an LED or something, which seems to sort of work. can anyone tell me what the transistor and rectifier actually do?