Error 1215 Mysql

Asked

Viewed 70 times

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.

Modelagem das Tabelas

  • Put the department table there in the question.

  • Does not add, it is easier to maintain.

  • I added the modeling of tables (how they should look at the end) to help.

  • 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)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.