Unless there is some compelling reason to do otherwise, you should  
make the primary key of school_attendees PRIMARY KEY (attendee_id,  
school_id). But this is a minor issue, DBIx::Class doesn't really  
care as long as the classes are in sync with the database.

Anyway, here's probably what you should be doing:

package DB::MyTestSchema::SchoolAttendee;
__PACKAGE__->belongs_to( school => 'DB::MyTestSchema::School',  
'school_id' )
__PACKAGE__->belongs_to( student  => 'DB::MyTestSchema::Student',  
'attendee_id' );

package DB::MyTestSchema::Student;
__PACKAGE__->has_many( school_attendees =>  
'DB::MyTestSchema::SchoolAttendee', 'attendee_id' );
__PACKAGE__->many_to_many( schools => 'school_attendees', 'school' );

package DB::MyTestSchema::School;
__PACKAGE__->has_many( school_attendees =>  
'DB::MyTestSchema::SchoolAttendee', 'school_id' );
__PACKAGE__->many_to_many( students => 'school_attendees', 'student' );

Dave

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to