restructured database, models and tests to create has_many_through relationships