If you want to prevent cavities, how often you eat can be just as important as what you eat. That is because food affects your teeth and mouth long after you swallow. Eating cookies with dinner will do less harm to your teeth than eating them as a separate snack. Of course, overall poor nutrition can contribute to periodontal disease. It also can have other long-term effects on your mouth.