Re: Foreign key as primary key...

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

From: fdsfds fdsfddsf
Subject: Re: Foreign key as primary key...
Date: 13:42 on 20 Feb 2005
 --- 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)

Foreign key as primary key...
jossblowing 15:11 on 18 Feb 2005

Re: Foreign key as primary key...
Tony Bowden 16:16 on 18 Feb 2005

Re: Foreign key as primary key...
fdsfds fdsfddsf 13:42 on 20 Feb 2005

Re: Foreign key as primary key...
Tony Bowden 14:48 on 20 Feb 2005

Re: Foreign key as primary key...
Joss Shaw 15:13 on 20 Feb 2005

Re: Foreign key as primary key...
Ofer Nave 20:26 on 20 Feb 2005

Re: Foreign key as primary key...
Joss Shaw 11:22 on 22 Feb 2005

Re: Foreign key as primary key...
Perrin Harkins 18:09 on 22 Feb 2005

Generated at 11:30 on 23 Feb 2005 by mariachi v0.52