You could try this:
CREATE TABLE ref1
(
id VARCHAR2(3) PRIMARY KEY
);
CREATE TABLE ref2
(
id VARCHAR2(3) PRIMARY KEY
);
CREATE TABLE look
(
p VARCHAR2(3),
CONSTRAINT fk_p_ref1 FOREIGN KEY (p) REFERENCES ref1(id),
CONSTRAINT fk_p_ref2 FOREIGN KEY (p) REFERENCES ref2(id)
);
Tested on a 10G R2 server with no complaint (yet).
Edit:
Simple test result:
SQL> insert into ref1 (id) values ('abc');
1 row created.
SQL> insert into ref2 (id) values ('def');
1 row created.
SQL> insert into look (p) values ('abc');
insert into look (p) values ('abc')
*
ERROR at line 1:
ORA-02291: integrity constraint (LINEQZ.FK_P_REF2) violated - parent key not
found
SQL> insert into ref2 (id) values ('abc');
1 row created.
SQL> insert into look (p) values ('abc');
1 row created.
ManagerandConsultanttables (both with 1:1 relationship withPerson). A person can be manager or consultant or both or neither. Then we have a tableDecisionwith a columnAuthorized_by_Person_IDwhich we want to ensure they (the decisions) are made by someone that is both a manager and a consultant. – ypercube Oct 11 '12 at 12:31Personreferences both of the other tables, then either it must beNULL(i.e. the person is neither manager nor consultant) or it must have a single value that matches rows in both of the other tables (i.e. the person is both manager and consultant). If you wanted the ability to be one or the other but not both, wouldn't you need two separate columns inPerson, one forManagerIDand one forConsultantID? – Dave Costa Oct 11 '12 at 12:40