We develop the basic constructions of homological algebra in the
(appropriately defined) unbounded derived categories of modules over algebras
over coalgebras over noncommutative rings (which we call semialgebras over
corings). We define double-sided derived functors SemiTor and SemiExt of the
functors of semitensor product and semihomomorphisms, and construct an
equivalence between the exotic derived categories of semimodules and
semicontramodules. In the final sections we construct model category structures
on the categories of complexes of semi(contra)modules, and develop
nonhomogeneous Koszul duality theory for semialgebras. Our motivating examples
come from the semi-infinite cohomology theory. Comparison with the
semi-infinite (co)homology of graded associative algebras and Tate Lie algebras
is established in appendices.