[Dbix-class] has_one joining through another table

Steve Francia steve at takkle.com
Wed Jun 27 16:58:40 GMT 2007


Thanks for the good advice and discussion.

So, taking your advice, actually brings it all back to the original
question.
I believe I understand what you are recommending.
So I created a fk_user_picture_id in the picture table which identifies
the owner through the user_picture table.

To me that is a has_one relationship between picture and user through
the user_picture table, which is actually the root question that started
this discussion.
Now that my database is in order, does anyone have any documentation or
tips on how to implement this.. I am not finding documentation and all
my attempts haven't seemed to work.
-Steve

Matt S Trout wrote:
> On Tue, Jun 26, 2007 at 04:30:26PM -0700, Marc Mims wrote:
>   =

>> * Steve Francia <steve at takkle.com> [070626 16:00]:
>>     =

>>> Sadly, that is the way we had it, we decided to switch to using the =

>>> owner flag to try to eliminate duplication of data in the database.
>>>       =

>> At least in the problem you presented, I don't see the data duplication
>> problem with a foreign key to the user table in the picture table.  The
>> key itself would exist in both the picture table and the user_picture
>> table, but I think that is a natural consequence of the relationships.
>>     =

>
> Actually, I'd probably have the owner_id be part of a compound FK to
> user_picture rather than user - enforces that that link exists ...
>
>   =


-- =

Steve Francia
Lead Developer
Takkle, Inc.
212.792.5859 (fax)
steve at takkle.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20070627/4b3=
91181/attachment.htm


More information about the Dbix-class mailing list