A cavity is when bacteria produces acid that destroys the tooth's enamel and it's underlying layer, the dentin.
Decay is influenced by lifestyle, what we eat, how well we take care of our teeth, and also heredity can play a role in how susceptible your teeth may be to decay.
The decay and any unsound tooth structure is removed, and then the tooth is filled using a white filling material, which can be composite resin or porcelain.