[Dbix-class] complex relationships I

Benjamin Hitz hitz at genome.stanford.edu
Thu Sep 20 23:24:11 GMT 2007


> In the Cv_term.pm module:
>
> __PACKAGE__->has_many(
>   "cvterm_relationship_child_cv_term_noes",
>   "DB::Mod::Cvterm_relationship",
>   { "foreign.child_cv_term_no" => "self.cv_term_no" },
> );
> __PACKAGE__->has_many(
>   "cvterm_relationship_parent_cv_term_noes",
>   "DB::Mod::Cvterm_relationship",
>   { "foreign.parent_cv_term_no" => "self.cv_term_no" },
> );
>
> In the Cvterm_relationship.pm module:
> __PACKAGE__->belongs_to(
>   "child_cv_term_no",
>   "DB::Mod::Cv_term",
>   { cv_term_no => "child_cv_term_no" },
> );
> __PACKAGE__->belongs_to(
>   "parent_cv_term_no",
>   "DB::Mod::Cv_term",
>   { cv_term_no => "parent_cv_term_no" },
> );
>
> So, I would guess I want to add:
>
> __PACKAGE__->many_to_many (children =>  
> 'cvterm_relationship_child_cv_term_noes', 'child_cv_term_no');
> and
> __PACKAGE__->many_to_many (parents =>  
> 'cvterm_relationship_parent_cv_term_noes', 'parent_cv_term_no');
>
>

I wanted to follow up here, since I know I made a mistake in part II.
First off, we only have single parents, but we specifically allow for  
(future tense) multiple parents.  "CV" stands for controlled  
vocabulary and we do have some (not loaded in these tables) which  
have multiple parentage (DAGs, not trees).

Second, do I need to reverse the 3rd argument in many_to_many calls  
above?  childred=>child, 'parent_cv_term_no'?

Ben

--
Ben Hitz
Senior Scientific Programmer ** Saccharomyces Genome Database ** GO  
Consortium
Stanford University ** hitz at genome.stanford.edu






More information about the DBIx-Class mailing list