On Thu, 19 Oct 2006, Drew Taylor wrote:

> One thing I discovered after my post which I think is CRITICAL:
> has_one & might_have both use the PK of the local (what's the proper
> terminology?) table as the FK into the foreign table. Perhaps saying
> something like this for the might_have docs:
>
> "Creates an optional one-to-one relationship with a class, where the
> primary key of the foreign class is equal to the primary key of the
> local table. Ie. Foo.id == Bar.id. Unlike belongs_to, might_have ONLY
> suppports using each tables primary key as the key column."
>
> I'm sure I said that in a very ineloquent way, but hopefully you get the idea.
>

belongs_to and has_one/might_have are complete opposites.. Yes the naming 
of belongs_to is rorrible, I blame mst (who will no doubt blame AR) ..

belongs_to means: a field (or fields) in THIS table is a foreign key 
(contains the primary key of) THAT other table.

has_one means: there is a row in THAT table which contains THIS tables 
primary key.

ditto might_have, except its not guaranteed to be there.

HTH
Jess

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to