A basic automotive 4-pin or 5-pin relay is composed of two halves:
A 5-pin relay adds pin 87a, which is also known as the N.C. (normally closed) position. This pin is connected to pin 30 when the relay is not energized (coil off).
Note: If you ignore pin 87a on a Bosch 5-pin relay, you'll have a fully functional 4-pin relay — just leave 87a unconnected.
For a animated walkthrough of how relays work, check out my YouTube Video here.
Going into a little more detail, the electromagnetic coil that's connected to pins 85 and 86 on Bosch-style relays may also come with a device called a diode between pins 85 and 86.
This means that you can only connect:
Cheaper relays will not have this diode inside, so pin 86 or 85 can be used as ground, and the remaining of the two pins can be used as power — polarity doesn't matter in that case.
Sometimes a 5-pin relay is needed in order to give the user the option to have the relay make a connection when it is not being powered between pins 30 and 87a (normally closed position).
The relay can also be wired in "reverse" so:
Or you can use two separate power sources (one on 87a and another on 87), and each can power a device via pin 30 — switching between them depending on whether the coil is energized or not.
I go over some advanced examples on the other page here.