Probably the worst thing you can do to your teeth is to drink a soda 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, soda, or juice, 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 that causes tooth decay!
It is important to be aware of all the possible sources of sugar out there. 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 mouth wash, or chewing sugarless gum can help. However, nothing has the effect of avoiding sugar!