A relay switch is an electromagnetic switch operated by a small electric current that can turn on or off a larger electric current source. The main part of a relay switch is the electromagnet. A good comparison is a nozzle on a faucet, where when you open the nozzle water comes pouring out and when you close it the water stops. A relay switch is the same concept only difference is it deals with currents. To explain, if the switch is enabled or open then the current flow is not obstructed and can flow to its destination, however, if the switch is disabled or closed, then the flow is blocked, and no electricity is flowed resulting in no power to the destination. Relay switches are not always used by themselves but rather with larger projects. There are several different circuits built from relay switches for different reasons a few worth mentioning are Micro-controller relay switch, Logic controlled relay switch, P-Channel MOSFET Relay Switch, etc.
Joseph Henry, an American in 1935 invented relays to demonstrate at the College of New Jersey. He used a small electromagnet to switch on and off a larger switch and in theory speculated it could be used to control other electrical machines over long distances. He then applied this idea to another invention which was the electric telegraph. Later, relays were used in telephone switching and even in early electronic computers. The relays remained quite popular until transistors came into the picture which was around the late 1940s.
Different projects use relay switches in different manners, but the principle remains the same in every project. To explain, as stated above the purpose of the relay switch is to prevent or allow current to go through to the destination or not, and regardless of where the switch is used in a project the purpose is always the same and does not differ. For example, let's take an electromagnetic door in a clinic or hospital that needs front-desk interaction to open, the way this project works is by using a relay switch. To elaborate, when the electric current is going through or in other words if the relay is on then the door is able to be pushed or turned open however if it’s the contrary and the electric current is not going through or the relay is off then the door remains locked due to the power of the magnet. Another example most people would be able to relate to fairly easily is a conventional light switch. The same principle applies, if the switch is on the relay is on allowing power to go through, however, if the switch is off the relay is off or it blocks the current from going through. As you can see a relay is really a binary answer 1 or 0 or yes or no. The gate will either be open or closed and it cannot be in-between.