Re: [CDBI] has_a relationship with non-primary column?
"Praveen Hombaiah" <[email protected]> Wed, 5 Sep 2007 14:38:19 -0400
| Newsgroups | gmane.comp.lang.perl.modules.class-dbi |
|---|---|
| Message-ID | <[email protected]> |
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
well.
package Department;
__PACKAGE__->table('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__->table('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 <[email protected]> wrote:
>
> On 9/4/07, Praveen Hombaiah <[email protected]> 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
>
--
Regards,
Praveen Hombaiah.
_______________________________________________
ClassDBI mailing list
ClassDBI-Ra3b/[email protected]
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi