Re: Foreign key as primary key...

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

From: Perrin Harkins
Subject: Re: Foreign key as primary key...
Date: 18:09 on 22 Feb 2005
On Tue, 2005-02-22 at 11:22 +0000, Joss Shaw wrote:
> That makes a lot of sense - however, doesn't it also
> say using has_a on the many side of the relationship
> (eg. the MonthlyStatement part) is dangerous if you
> are trying to inflate a foreign key which also happens
> to be a primary key on the many table. Thus look at
> using might_have instead.

You can never substitute might_have for has_a with the same database
table.  They don't do the same thing.

You're correct that putting a has_a on a foreign key which is also part
of a primary key will cause problems in certain situations.  The
might_have relationship is not a fix for this.  You won't actually see
the problems most of the time, but if you do run into trouble you can
override the accessor and do your own inflation.

I'd like to round up all the little problems that has_a on primary keys
can cause and look for a fix, but it's kind of a low priority for me
since the workaround is fairly simple.

- Perrin

(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