On 8/1/06, Anthony Gardner <[EMAIL PROTECTED]> wrote:
This may not completely answer your questions, but it might move you in the right directions:
1) On the many to many table design: The "school_attendees" table doesn't need its own "id" primary key field. It can (and arguably *should*) be built as:
CREATE TABLE school_attendees
(
attendee_id INTEGER NOT NULL REFERENCES students(id),
school_id INTEGER NOT NULL REFERENCES schools(id),
PRIMARY KEY(attendee_id, school_id)
);
I'm a newbie to ORM and DBIx::Class and I think my question will be bread and butter for you guys but I can't figure it out so don't flame me!!
This may not completely answer your questions, but it might move you in the right directions:
1) On the many to many table design: The "school_attendees" table doesn't need its own "id" primary key field. It can (and arguably *should*) be built as:
attendee_id INTEGER NOT NULL REFERENCES students(id),
school_id INTEGER NOT NULL REFERENCES schools(id),
PRIMARY KEY(attendee_id, school_id)
);
2) In DB::MyTestSchema::School, you have the load_components arguments backwards. Its PK::Auto first, then Core, like you have it in the other ones (order matters).
3) See http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/Manual/Cookbook.pod#Many-to-many_relationships for example of how to construct a many-to-many relationship helper on top of the two underlying one-to-many relationships you've built.
-- Brandon
_______________________________________________ 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]/
