Greetings fellow monks!

I am in the process of learning DBIx::Class and Catalyst. The examples below probably are not unique to Catalyst, however. At the moment, I am trying to wrap my mind around DBIx::Class relationships (yes, I have read the docs...and more).

The scenario is as follows:

I am presenting the following classes for constructive critique. I am particularly interested in whether or not I am declaring the intended relationships properly. If not, I would greatly appreciate your insight. Note that these classes are stored in separate files, and are documented with POD, which was not included in the examples.

package testDB::Member; use base qw / DBIx::Class /; __PACKAGE__->load_components(qw/ PK::Auto Core /); __PACKAGE__->table('members'); __PACKAGE__->add_columns(qw/ id name email password enabled /); __PACKAGE__->set_primary_key(qw/ id /); __PACKAGE__->has_many(profiles => 'testDB::Profile', 'membe +r_id'); __PACKAGE__->has_many(assigned_roles => 'testDB::AssignedRole', 'membe +r_id'); 1; package testDB::Profile; use base qw / DBIx::Class /; __PACKAGE__->load_components(qw/ PK::Auto Core /); __PACKAGE__->table('profiles'); __PACKAGE__->add_columns(qw/ id member_id server name /); __PACKAGE__->set_primary_key(qw/ id /); __PACKAGE__->belongs_to(member => 'testDB::Member', 'membe +r_id'); __PACKAGE__->has_many(assigned_roles => 'testDB::AssignedRole', 'profi +le_id'); 1; package testDB::AssignedRole; use base qw / DBIx::Class /; __PACKAGE__->load_components(qw/ PK::Auto Core /); __PACKAGE__->table('assigned_roles'); __PACKAGE__->add_columns(qw/ id member_id profile_id role_id /); __PACKAGE__->set_primary_key(qw/ id /); __PACKAGE__->belongs_to(member => 'testDB::Member', 'member_id'); __PACKAGE__->belongs_to(profile => 'testDB::Profile', 'profile_id'); __PACKAGE__->belongs_to(role => 'testDB::Role', 'role_id'); 1; package testDB::Role; use base qw / DBIx::Class /; __PACKAGE__->load_components(qw/ PK::Auto Core /); __PACKAGE__->table('roles'); __PACKAGE__->add_columns(qw/ id tag description enabled /); __PACKAGE__->set_primary_key(qw/ id /); __PACKAGE__->has_one(role_type => 'testDB::RoleType', 'role_ +type_id'); __PACKAGE__->has_many(assigned_roles => 'testDB::AssignedRole', 'role_ +id'); 1; package testDB::RoleType; use base qw / DBIx::Class /; __PACKAGE__->load_components(qw/ PK::Auto Core /); __PACKAGE__->table('role_types'); __PACKAGE__->add_columns(qw/ id name /); __PACKAGE__->set_primary_key(qw/ id /); 1;

Thank you for your time and wisdom. --Akoya


In reply to DBIx::Class relationships by Akoya

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.