In this thesis we have studied the physics of different ultracold Bose-Fermi mixtures in optical lattices, as well as spin 1/2 fermions in a harmonic trap. To study these systems we generalized dynamical mean-field theory for a mixture of fermions and bosons, as well as for an inhomogeneous environment. Generalized dynamical mean-field theory is a method that describes a mixture of fermions and bosons. This method consists of Gutzwiller mean-field for the bosons, and dynamical mean-field theory for the fermions which are coupled on-site by the Bose-Fermi density-density interaction and possibly a Feshbach term which converts a pair of up and down fermions into a molecule, i.e. a boson. Real-space dynamical mean-field theory incorporates the effect of an inhomogeneous environment caused e.g by a harmonic trap. The crucial difference of this generalized formalism to the standard DMFT is that every lattice site is treated differently due to the inhomogeneity in the system. Differentsites are coupled by the real-space Dyson equation.