If I have a parent table in Oracle, with two children, I know that I can enforce a FK so that the parent exists.
Is there a way to ensure that a child record only exists in one of the children, but not both?
In other words, disallow the insert into child1 if there is already a record with the same id in child1?
CREATE TABLE parent (
id VARCHAR2(10) NOT NULL PRIMARY KEY,
some_date VARCHAR2(10)
);
CREATE TABLE child1 (
id VARCHAR2(10) NOT NULL PRIMARY KEY,
some_date VARCHAR2(10),
FOREIGN KEY (id) REFERENCES parent(id)
);
CREATE TABLE child2 (
id VARCHAR2(10) NOT NULL PRIMARY KEY,
some_date VARCHAR2(10),
FOREIGN KEY (id) REFERENCES parent(id)
);