Question about this diagram
Yes, we need that diode - the so called flyback diode. It prevents the premature death of the transistor due to the voltage spike across the inductive load when its supply voltage is suddenly reduced or removed - aka when turning off the relay.