On Thursday, May 3, 2012 4:09:52 AM UTC-7, Michael Gliwinski wrote:
>
> Hi, 
>
> Just a quick question.  Why does a one_to_one association require that the 
> corresponding model/table (the one containing the FK) use a many_to_one? 
>

Because of how it is implemented.  The alternative would be a one_to_one 
option that basically used many_to_one internally.  There needs to be some 
way to tell Sequel which table has the foreign key, and the current 
solution seems easiest.
 

> Basically just asking as I'm trying to understand that better as I keep 
> forgetting about it. 
>
> Also, I know this is not a very common situation, but what if both tables 
> use 
> their own PK as FK to the other table (i.e. both tables have the same 
> PKs)? 
>
>
  Model1.many_to_one :model2, :key=>:id (assuming id is your pk)

Jeremy 

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/Kyic0K0HF7gJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to