[Dbix-class] Newbie to ORM and DBIx (pls help)

Brandon Black blblack at gmail.com
Tue Aug 1 18:23:33 CEST 2006


On 8/1/06, Anthony Gardner <cyclewood_ltd at yahoo.co.uk> wrote:
>
> 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:

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)
);

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_relationshipsfor
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/dbix-class/attachments/20060801/e7de574b/attachment-0001.htm 


More information about the Dbix-class mailing list