Mechanical relays are very noisy (electrically) and they can cause problems when connecting them to a PC digital I/O card, ranging from spikes on your analog measurements to computer lockups!
One must remember that relays consist of coils that are energized and de-energized, causing a set of contacts (or more) to open or close. Noise is generated from the collapsing magnetic field of the coil as well as arcing across the contacts.
The most common solution is to reduce the noise both across the coil AND across the contacts.
FOR AC VOLTAGE,
use a 220 Ohm resistor connected in series with a 0.1 uf capacitor, and then connect this circuit across the coil of the relay. It is best to do this as close to the relay as possible. Make sure that you select a capacitor that is rated for the AC voltage that you are using. An MOV (Metal Oxide Varistor) may also be used.
FOR DC VOLTAGE,
you would use a 1000 Ohm resistor in series with a diode (ie. IN4002) and put this circuit across the coil. Make sure that you put the diode + to the coil - (since you want to reverse the polarity)