Radio-frequency (RF) systems in particle accelerators are usually designed to transfer energy to the beam or to define its longitudinal structure. However, charged particles passing through an RF cavity induce a voltage which acts back on themselves and on subsequent particles. The additional contribution of the beam to the cavity voltage moreover changes the effective properties of the RF system and is generally referred to as beam loading. The fundamental theorem of beam loading is introduced to derive the effect of a single bunch passage through an RF cavity. The choice of the cavity parameters, notably shunt impedance divided by quality factor, plays an important role to reduce the beam induced voltage. Extending the single bunch case to the periodic passage of bunches allows to calculate the steady state cavity detuning due to beam loading for a continuous bunch pattern. Special emphasis is given to the partially filled ring, with gaps in the filling pattern, which is the most common case of transient beam loading in electron and hadron synchrotrons