0
First of all, I would like to say that I have checked several questions about this here and no solution has worked.
I am giving alter table in the working table to add two Foreign Keys...one of them works(num_department) but the other for some reason returns error 1215.
Follow the darlings:
alter table departamento
add num_sup int,
add num_departamento int,
add primary key(num_departamento,num_sup)
alter table funcionario
add num_sup int,
add num_departamento int,
add constraint fk_num_depart foreign key(num_departamento) references
departamento(num_departamento),
add constraint fk_num_supr foreign key(num_sup) references
departamento(num_sup)
I have tried to drop the table and check the fields, among other solutions, but nothing worked... What can be?
Follow the modeling of the tables.
Put the department table there in the question.
– Diego Vieira
Does not add, it is easier to maintain.
– Sveen
I added the modeling of tables (how they should look at the end) to help.
– dev-john
The FK has match with the original PK alter table function add num_sup int, add num_department int, add Constraint fk_num_depart_sup Foreign key(num_department,num_sup) References department(num_department,num_sup)
– Motta