The FK and referenced column must be the same type and size - currently, super_id is a VARCHAR type, and you try to reference emp_id which is a INT type.
Please help with the code by finding the error
CREATE TABLE employee ( emp_id INT PRIMARY KEY, first_name VARCHAR(40), last_name VARCHAR(40), birth_date DATE, sex VARCHAR(1), salary INT, super_id VARCHAR(40), branch_id INT );
CREATE TABLE branch ( branch_id INT PRIMARY KEY, branch_name VARCHAR(40), mgr_id INT, mgr_start_date DATE, FOREIGN KEY(mgr_id) REFERENCES employee(emp_id) ON DELETE SET NULL );
ALTER TABLE employee ADD FOREIGN KEY(branch_id) REFERENCES branch(branch_id) ON DELETE SET NULL;
ALTER TABLE employee ADD FOREIGN KEY(super_id) REFERENCES employee(emp_id) ON DELETE SET NULL;
Its showing Error: Referencing column 'super_id' and referenced column 'emp_id' in foreign key constraint 'employee_ibfk_2' are incompatible.
Please or to participate in this conversation.