I have created a table in oracle which has one FK that refers to 3 primary keys in 3 different table.But when I want to insert into it I see an error says parent key not found!what should I do?
CREATE TABLE A
( X char(11) not null,
id char(11) not null,
PRIMARY KEY(X,id),
FOREIGN KEY(id) REFERENCES B(employee_id),
FOREIGN KEY(id) REFERENCES C(customer_id)
);
Create a single parent table (for the sake of example I’ll call it Party). Reference the Party table from all three tables A,B,C. As a result, the multiple foreign keys would be replaced by one foreign key referencing the Party table. This is an example of a generalisation / specialisation, “subtype” pattern which you will find in many data modelling books.