The audio signal (assuming optical storage media like CD, DVD, SACD, etc.) follows this path,
Source > Digital to Analog processing > Amplifier > Speaker
Now the digital to analog processing can be done in one of the following,
1) Source - CD or DVD player when you use the RCA outs to pre-pro or receiver
2) Dedicated processor - Digital out from CD or DVD player to a pre-pro
3) Integrated processor - Digital out from CD or DVD player to a receiver
The digital in/ outs take the form of Optical or Coax connections.
does the optical cable replace the analog cables or does it add to them like the digital cable
An optical cable is a digital cable by definition, i.e. due to the nature of the signal it carries. It will replace the analog cables in situations generalized by points 2 and 3 above.
In any situation you will need to run either one, not both.