In this study, we present the relativistic and non-relativistic solutions of the Dirac equation with the spin symmetry for the generalized Cornell potential (GCP) using the wave function ansatz method in the existence of external magnetic and Aharanov-Bohm (AB) flux fields. The relativistic energy eigenvalues and the corresponding eigenfunctions are found for varied vibrational and magnetic quantum numbers. By adapting the GCP parameters, we derive the relativistic and nonrelativistic energy eigenvalues with and without external fields for a set of potential models including the Killingbeck, harmonic oscillator, pseudoharmonic, anharmonic, Cornell, Coulomb, Kratzer, and modified Kratzer potentials. Additionally, the nonrelativistic energy spectra of the Kratzer and modified Kratzer potentials are reported with and without external magnetic and AB flux fields for several diatomic molecules (DMs). We discovered that in the existence of external magnetic and AB flux fields, the non-relativistic energy spectrum increases and degeneracy disappears. Furthermore, the AB flux field has a stronger impact on the energy spectrum than the magnetic field. To substantiate our findings, we calculate the energy levels of the Kratzer and modified Kratzer potentials for diverse DMs and find that they are perfectly consistent with previous studies.