Ok, it's probably general knowledge that soda, candy etc. can cause cavities. What obviously is not common knowledge is that, with a good diet, it's possible to go through your whole life without getting a single cavity. Weston A. Price travelled around the world and looked at the teeth of many primitive tribes (still quite a few of them back in his days) and they had perfect teeth.
Sufficient mineral content in saliva and replacement of hydroxide by fluoride in the bioapatite tooth matrix affects the time factor.
So there are four ways to completely avoid cavities.
- Annihilate the mutans-type bacteria in your mouth, and prevent recolonization.
- Do not eat sugars.
- Remove all your teeth.
- Die.
Obviously, the latter two solutions can have significant negative side effects on your lifestyle. The mutans biofilm plaque makes it difficult to eradicate the bacteria.
If your saliva is well buffered and mineralized, it would be very rare for pH to dip below 5.5 and have minerals leach out of the teeth. Diet would certainly also help in this respect, especially with regard to calcium, phosphate, fluoride, vitamin D, and vitamin K.