Re: Foreign key as primary key...
[prev]
[thread]
[next]
[Date index for 2005/02/20]
--- Tony Bowden <tony-cdbitalk@xxxxx.xxx> wrote:
> On Fri, Feb 18, 2005 at 03:11:17PM +0000,
> jossblowing@xxxxx.xx.xx wrote:
> > I'm trying to apply CDBI to an existing DB schema.
> We've got a lot of
> > tables which use foreign keys as primary keys,
> either on their own, or
> > as part of a compound key. The documentation seems
> to suggest might_have
> > is the way forward but I seem to be encountering a
> few problems.
>
> Can you give an example of the schema?
>
> Tony
Sorry for the slow response and thanks for responding,
I've been out hiking for the weekend and have just got
back!
An example would be three tables:
System:
ID [PK]
Title
Text, etc.
SystemType:
ID *[PK/FK refers to System table]
Type
Name, etc.
So in System.pm I declare the following -
System->columns(Primary => qw/ID/);
System->has_many(types => 'SystemType');
In SystemType.pm I declare -
System->columns(Primary => qw/ID/);
System->might_have(ID => 'System');
Is that the wrong way to go - should I be creating a
custom 'ID' subroutine in SystemType.pm ? I greatly
appreciate your help.
>joss
___________________________________________________________
ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com
|
(message missing)
|