package Node; use base 'My::Class::DBI'; ... # standard Class::DBI stuff here # Declare that we have a relationships table that # tells us where our children are Node->has_many('children_refs' => 'Relationship' => 'parent_id'); # Now that we can fetch those records from the # relationships table, we need to have a way to # get Node objects from those relationships sub children { return Node->search_in( Node->primary_column => [ map { $_->child_id } shift->children_refs ] ); } # Similarly for parents