Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: Foreign key pointing to multiple tables

Re: Foreign key pointing to multiple tables

From: --CELKO-- <joe.celko_at_northface.edu>
Date: 22 Sep 2003 12:30:05 -0700
Message-ID: <a264e7ea.0309221130.64fc919d@posting.google.com>


Yep, we need a priamry key in each of the job tables to prevent duplicates.

CREATE TABLE A_jobs
(job_ticket INTEGER NOT NULL PRIMARY KEY

        REFERENCES Tickets(job_ticket),
 job_type CHAR(1) DEFAULT 'A' NOT NULL

       CHECK(job_type = 'A'),
 FOREIGN KEY(job_ticket, job_type)
 REFERENCES Tickets (job_ticket, job_type)   ON DELETE CASCADE
  ON UPDATE CASCADE,
 ...);

But I do need the FOREIGN KEY (job_ticket, job_type) to make that the job_ticket bellongs to one and only one job_type. Received on Mon Sep 22 2003 - 14:30:05 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US