Re: Foreign key in Oracle Sql

From: Skarjune <dhs_at_wordimage.com>
Date: 6 Jan 2005 10:27:49 -0800
Message-ID: <1105036069.494749.61520_at_z14g2000cwz.googlegroups.com>


If you want to enforce Referential Integrity for a true relational database, you should use both the Primary Key constraints and the Foreign Key References constraints.

I'm not on Oracle, so I can't speak to the syntax, but conceptually looks fine, as your Rental table is a classic intermediary entity for data transactions.

-DH Skarjune

Silver wrote:
> 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 - 19:27:49 CET

Original text of this message