A Relay is an electrical component where one electric circuit can switch one or more separate electric circuits. A typical relay consists of a coil which when energized becomes an electromagnet, attracting a metal armature on which the switch contacts are mounted. This has many uses for model railroads.
A common example is the starter solenoid in a car. Heavy wires run to the relay and then to the starter motor. Low current, light gauge wires connect the coil to the battery via the ignition switch. This way heavy currents can be switched at a lower cost, without running heavy wires to the driver's position, and using a heavy duty switch to control the operation of the starter. It also isolates other circuits from the starter motor circuit. (It may be called a solenoid, in some cases it is a relay, in others it is employed as a solenoid.)
Applications with DCC
Small reed switches are used in some locomotives for programming purposes. Unlike a relay, they lack an electromagnet. The magnetic force needed to close or open the switch is supplied by a small external magnet, on a wand or similar tool. Some Atlas locomotives equipped with QSI decoders use this device. Passenger cars with battery powered lighting may also use a reed switch to control the lighting.
Reed Relays are also available, they include a coil to operate them.
A typical relay only requires an operating current measured in mA, for example 100mA. But the contacts it operates can carry much larger currents, ten to a hundred times larger. So for example, a stationary decoder with a limited output current can be used to operate a larger current accessory if a relay is used.
Relays used in model railroads typically have low voltage coils, from about 5V to 16V, but the output can be used to switch higher (or lower voltages). Using them to switch household mains voltage is also possible but you should be extremely careful mixing mains voltage with model railroad voltages. If you do, this should be in a separate enclosure away from all your other circuits and grounded if it is made of metal.
In this type of application a relay is often called a "contactor".
Relays can operate on DC but switch AC circuits, or vice versa. In fact, all combinations of AC or DC coils and AC or DC contacts are possible. So this can allow a DC output of a stationary decoder to operate an AC accessory.
Note that relays specifications differ depending on whether the supply is AC or DC. Coils are usually specified one way or the other. Contacts are usually specified both ways and are typically rated higher for switching AC voltages and currents.
A relay only requires one operating circuit but can switch multiple circuits and each circuit can be both normally open and normally closed. This can be used to increase the number of switching circuits on a turnout motor. For example a Tortoise Slow Motion Switch machine has 2 SPDT accessory switches but by using one of them to switch a DPDT relay you can increase that to 3 circuits.
There is no electrical connection between a relay's operating coil and contacts and therefore the two circuits are completely isolated. This allows one circuit to operate another circuit that cannot share a common ground or common return.