You're right - that should work. You'd end up with two foreign keys in the addresses table, only one of which would be valid in each row:
addresses - id - person_id - company_id Then each person and company would have its address found properly. Each address would have both a person and a company, although one would be empty which isn't a big deal. Maybe the appeal of the Rails approach is that it scales better. Instead of one foreign key for each model that can have an address, you have one foreign key and one column that holds the name of the model it refers to. 2 columns is better than n columns as n increases. On May 4, 1:08 pm, "John David Anderson (_psychic_)" <[EMAIL PROTECTED]> wrote: > On May 4, 2007, at 10:17 AM, [EMAIL PROTECTED] wrote: > > > > > Sometimes you'd like a single common model to be able to belong to > > multiple other models: for example, an Address could belong to a > > Person or a Company. Rails has Polymorphic Associations to handle > > this: > > >http://wiki.rubyonrails.org/rails/pages/PolymorphicAssociations > > > Does CakePHP have an easy way to handle these situations? > > How does this differ from just assigning: > > Address belongsTo Person > Address belongsTo Company > > ? > > -- John --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. 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/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
