This is going to be a has_many :students through => classes with models Students, Teachers, and Classes. This will help build a better understanding of different relational database structures.