You have seen that iron is better protected against corrosion by a metal which is a member of a couple having a more negative electrode potential than iron.
Magnesium is another example of a metal which prevents or greatly reduces corrosion of ships hulls or bridge pylons due to reaction of the iron contained in these with dissolved oxygen.
O
2(g) + 4H
+ + 4e
– 
2H
2O
AND
Mg

Mg
2+ + 2e
–rather than
Fe

Fe
2+ + 2e
–As the magnesium or zinc electrode is destroyed in the process, it is called a sacrificial anode.