The primary use of a relay is to create versatility in wiring designs using many different combinations to create large load operations with small voltage control.

A - Electromagnet
B - Spring to retract the contact when the magnet is not energized
C & D - Controlled circuit, on when the magnet is energized
and off when the magnet is not energized.
E - Power to energize the electromagnet
NOTE: C & D connections are completely isolated from the E contacts.
In the diagram if you apply dc power to the E contacts , a magnetic field is created at A, this magnetic field is strong enough to overcome the strength of the spring B, and attracts and pulls down the flexible armature connected to C towards the electromagnet and thereby closing the contact which connects the circuit between C and D. When power is removed from E (supplying power to the electromagnet ), it collapses the magnetic field on the electromagnet A, and the spring B will pull the armature back disconnecting the contacts and breaking the circuit between C & D.
The following diagram is also a basic relay but configured in such a way that momentary contact buttons can be used to engage or disengage the relay.
Latching Relays are also referred to as "Holding Circuits"
F - The trigger power source.
G - A push to disconnect button, normally is always on unless actually pushed, will reconnect when you let go of the button
H - A push to connect switch, only connects the circuit when pressed , when you let go of the button , the connection is broken.
Look on the first diagram on this page for the remaining legend references.
Pushing the button at H will energize the electromagnet, close the load contacts in the relay, then will stay latched after the H button is released because the load contact has now provided another route to complete the trigger power for the electromagnet. To unlatch , push the G button which will cut the trigger power and unlatch the relay. These types of relay wiring configuration would have multi sets of contacts within them , and only one set of latching contacts would be used for the latching circuit , and another isolated set of load contacts would be the actual relay switch for an independent circuit.
To wire a 2 button on / off switch for such a latching relay, for would need a 3 wire cable that is rated to handle the type of voltage/current needed for the trigger voltage only and NOT the load voltage / current that relay is controlling.
A self locking relay that takes power to change from the open to closed or closed to open but no coil power is required to keep it in a certain position.
There is also electronic type relays that is packaged in the form of an IC chip that is mounted to a heat sink to dissipate heat that is generated , this electronic type has no moving mechanical parts, the theory behind how the electronic version works is beyond the scope of this article.