In this work, we compute masses and magnetic moments of the heavy baryons and tetraquarks with one and two open heavy flavors in a unified framework of MIT bag model. Using the parameters of MIT bag model, we confirm that an extra binding energy, which is supposed to exist between heavy quarks ($c$ and $b$) and between heavy and strange quarks in literatures, is required to reconcile light hadrons with heavy hadrons. Numerical calculations are made for all light mesons, heavy hadrons with one and two open heavy flavors, predicting the mass of doubly charmed baryons to be $M(Xi _{cc})=3.604$ GeV, $M(Xi _{cc}^{ast })=3.714$ GeV, and that of the strange isosinglet tetraquark $udbar{s}bar{c}$ with $J^{P}=0^{+}$ to be $Mleft( udbar{s}bar{c},0^{+}right) =2.934$ GeV. The state mixing due to chromomagnetic interaction is shown to be sizable for the strange scalar tetraquark $nnbar{s}bar{c}$.