Dental caries is a multifactorial disease that affects the hard tissue of the teeth.
Cavities occur when the bacteria that we have in the mouth congregate on the surface of the teeth and in the presence of carbohydrates (sugars).
The acid formed by these bacteria attacks the surface of the tooth destroying it.
At first it only affects the enamel, the outermost layer of the tooth. If it advances, the bacteria can access the dentin, causing sensitization to cold or heat. And it can even affect the pulp (nerve), causing pain, since that is where the nerve endings are located, if this happens a root canal would be performed (killing the nerve).