Sugar is the main cause of dental decay when there are bacteria present. More significant than the amount of sugar you eat is the frequency of consumption.
Probably the worst thing you can do to your teeth is to drink a soda, sports drink or juice and have a sip every few minutes over a long period of time; the same is true for snacking. It is recommended that if you want to have a snack or sugary drink it is better to have it after food, as dessert, or have it in one sitting. Eating or drinking something sweet over an extended period of time creates a constant supply of sugar for bacteria and can cause tooth decay!
It is important to be aware of all sources of sugar. It is not just everything that is sweet, but anything that can turn to sugar like pieces of bread. Cutting down your sugar intake is good for cavity prevention, as well as your general health.
But what about when you have to have sugar? The best way to avoid cavities is to prevent the sugar from staying next to your teeth. Brushing after eating sugar, rinsing your mouth with fluoride mouthwash, or chewing sugarless gum can help. However, nothing is better than avoiding sugar!
Another group of food that causes significant damage to tooth structure is acidic foods. If in frequent contact with teeth, things like lime, lemon, and grapefruit can cause serious, irreversible damage (erosion) to your teeth.