BASICS:
the RELAY as a separate device, requires power. you can get relays that are less than 5v, are 5v, 12v, AC, DC or whatever
the relay is mounted on a board with other parts to make a device.
the power you feed the board is SEPARATE from the SIGNAL you send. NEVER FEED A RELAY POWER FROM THE ARDUINO BOARD.
on relay boards that have the signal to a board with a different voltage than the relay, the opto is a very good way to separate the two power supplies and DO NOT require a common ground.
for a relay board that does have a 5v power and your output is 5v AND you want to use transistors, you must tie the grounds together. The vast majority of cheap relay boards use opto's because the application is nearly universal. the market for 5v relays with transistors is nearly insignificant.
the opto allows complete separation of power sources.
the basic operation of the opto is exactly the same as and LED. all you need to do is to light the LED inside of the opto.
POWER SUPPLIES :
with relays, I like having a separation of power supplies. it removes one possible problem with noise.
second, your relays will consume power . if you have a raw, dirty 5v, the relay will be happy. the Arduino ? not so much.
if you have 12V, and you need to drop that to 5 for the arduino AND the relays, you need a larger voltage regulator. AND it has to be separate and filtered from the arduino.... or, just use that raw 12v to power the relays.