Re: Foreign key in Oracle Sql

From: -CELKO- <jcelko212_at_earthlink.net>
Date: 6 Jan 2005 14:11:51 -0800
Message-ID: <1105049511.118375.152720_at_z14g2000cwz.googlegroups.com>


>> How do I define this table in SQL ? <<

Using Standard SQL and ISO-11179 data elemet names, you want something like this:

CREATE TABLE Rentals
(user_id NUMERIC (4) REFERENCES Users(user_id) ON UPDATE CASCADE,
tape_id NUMERIC (10) REFERENCES Tapes (tape_id) ON UPDATE CASCADE
ON DELETE CASCADE,
rental_date DATE DEFAULT CURRENT_TIMESTAMP NOT NULL,
... -- other stuff, price, dues date, etc. PRIMARY KEY (user_id, tape_id, rental_date ));

Yes, you have to include the natural primary key.

I would make tape_id into a UPC code plus an accession number, so you can track the copies of each tape as well as the titles you stock. Received on Thu Jan 06 2005 - 23:11:51 CET

Original text of this message