Martin Schapendonk wrote: > On 10/11/06, AD7six <[EMAIL PROTECTED]> wrote: > > >However, strictly speaking it does not provide any way to prevent an > > Address to belong to a Person and an Organization at the same time. > > > > ? > > > > If on the address table there are 2 fields 'class' and 'foreign_id' > > which are used to define to which class and object the address relates > > it is not possible for the same address to point to more than one > > person/org. If you are defining in the person/org class which is their > > address by setting a field named address_id the foreign key is in the > > wrong table. > > In that case, you're right. > > I was thinking about an addresses table with two columns "person_id" > and "organization_id". This does not prevent an address from belonging > to an organization and a person at the same time. > > I think the "foreign_id" column pointing to either persons or > organizations is not such a nice solution, since it removes the > possibility of having a foreign key relation in the database. > > In the database (in my case, usually Oracle) I would implement things > with an optional foreign key relation and a check constraint that > specifies that only one of the two columns may be filled. I was > looking for some similar functionality in CakePHP. > > Regards, > > Martin > > -- > Martin Schapendonk, [EMAIL PROTECTED]
Just my 2 cents. Keep addresses in an address table. A join table could connect contacts to addresses - likewise for companies and addresses. Disallowing a company to have the same address as a contact is going to eventually bite you in the ass. I for one do private contract work from my home. My own companies address is my home address. I could be a contact REQIURING a company address identical to my personal one. Abba Bryant --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
