Subject | Re: problem adding foreign key |
---|---|
Author | Adam |
Post date | 2005-02-07T03:04:25Z |
My guess is that you have some "contacts" records without a parent
record in the customer table. What does this query return?
select *
from contacts
where customerid not in
(select id from customer);
You are allowed to have more than one table with a foreign key to the
same parent field, so that won't be it.
Adam
--- In firebird-support@yahoogroups.com, "markd_mms" <spam@m...>
wrote:
record in the customer table. What does this query return?
select *
from contacts
where customerid not in
(select id from customer);
You are allowed to have more than one table with a foreign key to the
same parent field, so that won't be it.
Adam
--- In firebird-support@yahoogroups.com, "markd_mms" <spam@m...>
wrote:
>making a
>
> hi. i'm pretty new to firebird and sql so i'm not sure if i'm
> stupid mistake...ID
>
> i have 2 tables, contacts and customers. customers has a pk called
> and contacts has a field (with no contraints) called CustomerID.table "CUSTOMERS"
>
> when i execute the following sql i get an error...
>
> alter table CONTACTS
> add constraint FK_CONTACTS_CUSTOMERS
> foreign key ("CustomerID")
> references CUSTOMERS(ID)
> on delete CASCADE
> on update CASCADE
>
> and the error is...
>
> violation of FOREIGN KEY constraint "PK_CUSTOMERS" on
>
> there is another table with a foreign key on Customers.ID. i'm not
> sure if this makes a difference.
>
> running v1.5.2.4731
>
> any ideas?
>
> TIA