Re: Order of Table Creation and Foreign Keys
Date: 1995/11/26
Message-ID: <pplewe19-2611952028450001_at_dal08-17.ppp.iadfw.net>#1/1
In article <499mmi$8sd_at_s02.pavilion.co.uk>, diamond_at_pavilion.co.uk (diamond) wrote:
> I am creating a small d/b (about 10 tables) and have written and tested the
> SQL scripts to create and populate each table. When I try to add Foreign Keys
> to some tables, I get error message 'Cannot Add Referential Constraint -
Parent Keys
> Not Found'.
>
> I think this is something to do with the order in which I create the
tables and Primary Keys
> thereon. Is this the case ?
You're right - a foreign key has to refer back to a primary or unique key on the parent table. You can't create them in the reverse order. We use Designer/2000 and it seems to handle this OK - I haven't had constraint or table creation fail for non-data reasons.
Patrick Plewes
pplewe19_at_iadfw.net
Received on Sun Nov 26 1995 - 00:00:00 CET