A relay is a very simple device consisting of an electromagnet, an armature (a switch that closes when attracted by the electromagnet), and a spring that is connected to the armature. You can see in the diagrams (Source: How Stuff Works) how the relay works.
In Figure 1 of the diagram, there are two circuits. The first circuit is a battery (3 volts), a switch and an electromagnet. The second circuit is a battery (6 volts), a light bulb and the relay’s armature. While the switch to the electromagnet is off, no current can flow from the 3 volt battery through the electromagnet. So, the armature-switch is off and no current can flow from the 6 volt battery to power the lamp in the second circuit.
In Figure 2 the switch to the electromagnet circuit is switched on. When current from the 3 volt battery flows through the electromagnet, the electromagnet creates a magnetic field that attracts the armature to close the circuit to the lamp. Now current can flow from the 6 volt battery to the lamp, and the lamp lights up.
If you look closely at Figure 2, you’ll notice that while the armature-switch is closed allowing the current in the lamp circuit to flow from the 6 volt battery to the lamp, it does not come into contact with the electromagnet.
This means that the 6 volts from the lamp circuit cannot flow into the electromagnet circuit. Thus, the 3 volts in the electromagnet circuit and the 6 volts in the lamp circuit remain separate.
This is the electronic schematic diagram of a relay. The curly line represents the electromagnetic coil and the vertical lines represent the metal core the coil is wrapped around. The switch at the top of the diagram represents the armature.
Build the circuit demonstrated in the photographs.
When you press the Press Switch (S1) you will hear the relay click as current passes from the 3 volt battery block (B1) through the electromagnet. The electromagnet creates a magnetic field that attracts the metal armature.
When you release the Press Switch you will hear the relay click again since the current has been cut from the electromagnet. This causes the electromagnetic field to collapse so the armature is no longer attracted by the electromagnet and the spring attached to the armature returns the armature to its rest position.
Often when using electronic relays in circuits it is recommended that you insert a flyback diode to protect sensitive electronics. The magnetic coil in the relay stores electricity like a capacitor and when the voltage is cut from the coil the current can flow back into the circuit in a way that is undesirable.
I've included the red LED to demonstrate this phenomenon and you can review this video to watch the LED flash when I release the Press Switch (S2).
We'll assume you're ok with this, but you can opt-out if you wish.