| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Foreign key in Oracle Sql
>> 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 - 16:11:51 CST
![]() |
![]() |