[CDBI] has_a relationship with non-primary column?

Praveen Hombaiah phombaiah at gmail.com
Wed Sep 5 19:38:19 BST 2007

Thanks for your help.

I should have mentioned that not only is this a non-primary key as far as
the database is concerned but a non-primary key in the class-dbi code as

package Department;

__PACKAGE__->columns(All => qw/real_pk desired_column dept_name/);
__PACKAGE__->columns(Primary => qw/real_pkid/);

__PACKAGE__->has_many( options => 'Employees' );

package Employee;

__PACKAGE__->columns(All => qw/emp_id department employee_name/);
__PACKAGE__->columns(Primary => qw/emp_id/);

# Is it possible to link this relationship with
employee.desired_columninstead of
# employee.real_pk?
__PACKAGE__->has_a( department => 'Department' );

On 9/4/07, Perrin Harkins <perrin at elem.com> wrote:
> On 9/4/07, Praveen Hombaiah <phombaiah at gmail.com> wrote:
> > Is it possible to setup a has_a relationship with a non-primary key
> column?
> Yes, if the column is unique.
> > If so, how can it be expressed.
> The usual syntax should work.
> - Perrin

Praveen Hombaiah.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digitalcraftsmen.net/pipermail/classdbi/attachments/20070905/ca7443d5/attachment.htm

More information about the ClassDBI mailing list