Re: How could I model this relationship?
Date: Tue, 25 Jun 2002 15:06:31 +0200
Message-ID: <20020625150631.30c89fbb.pavel_at_ifjf.uib.no>
On Tue, 25 Jun 2002 13:18:00 +0100
"Stu" <smcgouga_at__at_yaho.com_> wrote:
> Hi,
Regards,
>
> I have a relationship: many companies have many customers. but a customer
> is also a company! So how would I model this in a relational db?
>
> Could I just have the company with a relationship going straight back into
> company (EER)? If so How do you transfer this to tables?
>
> cheers
> stu
>
>
Yes, company entity can make relationship to the company entity.
If customer is always a company then it can be represented:
table companies (id_company)
table customers (id_company, id_customer), primary key (id_company,id_customer)
foreign key from customers (id_company) to companies (id_company)
foreign key from customers (id_customer) to companies (id_company)