Re: Question on how to implement Class::DBI with crossover tables..

[prev] [thread] [next] [Date index for 2005/03/02]

From: William Ross
Subject: Re: Question on how to implement Class::DBI with crossover tables..
Date: 21:01 on 02 Mar 2005
On 2 Mar 2005, at 17:37, d. Taylor Singletary wrote:

>
>  Hi there,
>
>  New to the list and new to Class::DBI. I've read through the 
> documentation and tutorials and they all seem to assume that related 
> tables/objects would have the related fields within the tables...
>
>  that doesn't make much sense. Here's the way we do relationships 
> around here:
>
>  We'll have a table called CONTACT with a primary key of CTCTID.
>  We'll have a table called CUSTOMER with a primary key of CSTMRID.
>  We'll have a table called VENDOR with a primary key of VNDRID.
>
>  Then we'll have two crossover tables:
>  XCONCUST with a primary of XCONCUSTID, with the fields CTCTID & 
> CSTMRID tying the records together.
>  XCONVEN with a primary key of XCONVENID, with the fields CTCTID & 
> VNDRID tying the records together.

The other options mentioned here will no doubt offer more, but your 
immediate need is more easily met like this:

   Vendor->has_many(contacts => [ 'Vendor::Contact' => 'CTCTID' ]);

It's in the Class::DBI docs under relationships/has_many/mapping. I 
think you still need to have a Vendor::Contact package in your tree, 
but you don't have to worry about its relationships or even columns 
unless you decide to start holding more information there.

best

will




>
>  Is it possible with Class::DBI to semi-transparently manage the 
> crossover tables and still assert relationships like Vendor::Contact, 
> Customer::Contact? How is that done? When accessing these objects I 
> don't want to have to think about maintaining the relationships in the 
> crossover tables at all. Customers can have many contacts, Vendors can 
> have many contacts.
>
>  Thanks for a push in the right direction on this.
>
>  d. Taylor Singletary 

Re: Question on how to implement Class::DBI with crossover tables..
William Ross 21:01 on 02 Mar 2005

Creation of composite objects automatically
Peter Speltz 22:32 on 02 Mar 2005

Generated at 00:32 on 04 Mar 2005 by mariachi v0.52