On Wed, Apr 3, 2013 at 8:55 AM, Peter Rabbitson <rabbit+d...@rabbit.us>wrote:

> On Wed, Apr 03, 2013 at 08:41:05AM -0700, Rippl, Steve wrote:
> > Have I given you enough info?
>
> I think so but I want to make sure I got it right. Tell me if the thing
> below is correct:
>
> $course_section_rs->search({}, {
> join => [
>   { 'course' => [     <------------------- me -> belongs_to(course)
>     { course_coursetypes  => 'type' }, <-- me -> belongs_to(course) ->
> has_many(course_coursetypes) -> belongs_to(type)
>     { course_grades => 'grade' }, <------- me -> belongs_to(course) ->
> has_many(course_grades) -> belongs_to(grade)
>     'course_locations',  <---------------- me ->
> has_many(course_locations)  (this one is not referenced anywhere - mistake?)
>   ] },
>   { 'section' => { 'section_staffs' => 'staff' } } me ->
> belongs_to(section) -> has_many(section_staffs) -> belongs_to(staff)
> ]})
>
> If this is true (specifically the has_many(section_staffs) part) then this:
> > Each Section only has one teacher and belongs to one course
> can't be correct...
>
> Please clarify ;)


You are correct with the relations, logically each section should only have
one teacher but I haven't specified that and the above relations are the
ones auto-generated.  I have "CONSTRAINT section_id_staff_id PRIMARY KEY
(section_id, staff_id)" on the section_staff table when I guess just
staff_id should be the primary key?

The joins to course_coursetype and course_locations are there because in
some contexts I want to filter by location or type so my original $search
would change accordingly, but right now I'm trying to get the most general
case to work.

Thanks
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to