Since calcium and magnesium in water both carry positive charges. This means that these minerals will cling to the beads as the hard water passes through the mineral tank. Sodium ions also have positive charges, albeit not as strong as the charge on the calcium and magnesium. When a very strong brine solution is flushed through a tank that has beads already saturated with calcium and magnesium, the sheer volume of the sodium ions is enough to drive the calcium and magnesium ions off the beads. In ion exchange, hard water ions replace sodium ions on beads.
Process is reversed to flush minerals away.