Foreign key in Oracle Sql

From: Silver <argytzak_at_med.auth.gr>
Date: Thu, 6 Jan 2005 18:27:12 +0300
Message-ID: <crjom5$5rm$1_at_nic.grnet.gr>



Hi everybody and happy new year,

I was wondering this:

suppose we have 3 tables called 'rental', 'tape' and 'user'. The table rental contains 3 columns, 'userID', 'tapeID' and 'date'. Now, all those 3 columns make up the primary key of the table 'rental'. How do I define this table in sql ?
Do I have to include the constraint PRIMARY KEY as well as the constraint REFERENCES , iike this:

CREATE TABLE Rental (

    userID number(4) constraint fk_userid references USER(userID),     tapeID number(4) constaint fk_tapeid referenes TAPE(tapeID),     dateOfRental date,

    constraint pk_rental (userID, tapeID, dateOfRental)

Thanks! Received on Thu Jan 06 2005 - 16:27:12 CET

Original text of this message