How to allow multiple records to use one foreign key value in heidisql

429 views Asked by At

I am using HeidiSQL to create a database.I've been struggling with inserting data into the columns, as i receive the following error " SQL Error (1062) : Duplicate value on "" and key "".I have two tables.

Employee table which has the following columns

name varchar (50);

empId int not null primary key;

Fk_deparmentId int not null;//this is the foreign key from the department table.

in the Department table which has the following columns

departmentId int not null primary key;

dep_name varchar(50);

Now my problem is that when i insert values into the employees table the SQL Error(1062):Duplicate entry on "the value i inserted" and key" the value that matches" is raised. Please help i have checked the data types and collation they match on both columns. and the DepartmentId is set as a foreign key in the employees table. Thanks in advance.

0

There are 0 answers