LRaiz
2006-Dec-29 20:29 UTC
How do I chose a table to contain a foreign key for one-to-one relationship?
Are there some fundamental database considerations for selecting which side of one-to-one relationship should store foreign key? This question does not come up in one-to-many relationships but what are the considerations in one-to-one case? Let say for example that in my RoR application I have models for purchase order and invoice. Do I select that Order has_one Invoice and Invoice belongs_to Order or do I swap has_one/belongs_to usage? Both options provide me with methods to access order from invoice and visa versa. Given the fact that placement of belongs_to corresponds to a table which contains foreign key the equivalent question is how one decides to put order_id foreign key into Invoices table or invoice_id into Orders table? How much does it really matter which option I go with? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---