Check constraints Foreign Key

From: David Zlotchenko <zlotchen_at_solar.rtd.utk.edu>
Date: 2 Dec 1994 02:15:53 GMT
Message-ID: <3bm00p$dkg_at_martha.utk.edu>


Could anyone explain me how exactly the "FOREIGH KEY" constraint serves?

I thought that if I have a local PRIMARY KEY field(s) tied with the PRIMARY KEY field of a master table by FOREIGH KEY constraint, I am  getting one-to-one relationship.

Assuming that, I've tryed use to values from the master table for CHECK contstraints in other fields of the dependent table.

I wrote this:

create table JOBS (
JCODE char(4) not null PRIMARY KEY , MIN_PAY number(7) not null,
MAX_PAY number(7) not null
);

create table ASSIGNMENT (
EID char(5) not null,
JCODE REFERENCES jobs(jcode),
SALARY number(7)
  check( salary >= jobs(MIN_PAY) and salary <= jobs(MAX_PAY)) FOREIGN KEY EID,JCODE EMPLOYEE(EID), JOBS(JCODE), PRIMARE KEY (EID,JCODE)
);

I expect jobs(MAX_PAY) and jobs(MIN_PAY) be definite single values because of the PRIMARY KEY/FOREIGN KEY constraints.

ORACLE does not let to use other table's columns in check statment. Why this could not work?

--
David Zlotchenko
Computer Science Undergraduate Student Assistant
Research Services
The University of Tennessee            Phone: (615) 974-2909
211 Hoskins Library                    Email: zlotchen_at_solar.rtd.utk.edu
Knoxville, TN  37996                          s_dzlotchenk_at_pstcc.cc.tn.us
Received on Fri Dec 02 1994 - 03:15:53 CET

Original text of this message