A relay can be thought of as a toggle switch that is controlled by your program instead of by physical interaction. Relays are often used to automate lights, heaters, or fans based on environmental sensor data or a pre-programmed routine.
There are two major categories of relay: Mechanical relays, and Solid-state Relays (SSRs). Mechanical relays use an electromagnet and a spring to physically open or close the connection. The advantage of mechanical relays is that they are less expensive than SSRs, but they have a shorter lifespan because of the moving parts and other issues. Solid state relays use transistors to open or close the connection, and therefore have no moving parts and make no sound when switching.