Re: Can ref_int be defined with standard SQL at all?
Date: Tue, 16 Jan 2001 14:37:16 GMT
Message-ID: <941mas$luu$1_at_nnrp1.deja.com>
In article <3A6412C4.424B8B59_at_ijs.si>,
DT <denis.trcek_at_ijs.si> wrote:
> Can anybody please let me know how to set up referential integrity
> using standard SQL - I don't want to deal with tricks like MS SQL
> Server 7.X triggers...
>
> So, the bottom line question is: What are the standard SQL statements
> to
> make ref. int. between e.g. the following two relations (Customer_ID
is
> a foreign key in the second table):
>
> (#Customer_ID, Name, Surname) and (#Item_ID, #Customer_ID, Quantity).
>
> Thank you for your answer in advance. D. Trcek
>
>
ANSII-92 standard SQL for foreign key constraints in your examples is:
CREATE TABLE Table2
(
ItemId integer,
Customer_Id integer REFERENCES Table1 (Customer_ID),
Quantity integer
)
or:
CREATE TABLE Table2
(
ItemId integer, Customer_Id integer, Quantity integer,
FOREIGN KEY (Customer_ID) REFERENCES Table1 (Customer_ID) )
The second style can be used for multi-column foreign key references.
-- Vaughan Powell MCDBA, MCSD, MCSE Sent via Deja.com http://www.deja.com/Received on Tue Jan 16 2001 - 15:37:16 CET