the relationship between departments, classes and class_instances is rather hard coded into dotlrn from what i can tell. In fact, i am trying to get dotlrn working with a similar configuration you are talking about (one class can belong to some departments) and i also want classes and departments to become communities. In the current dotlrn version, those are not communities themselves.
Departments and classes are not communities but only community-types and you will probably have to change that. How you model the relationship between them afterwards is rather unimportant i think.