im having issues with the below in mysql. i get an error (ERROR 1215: Cannot add foreign key constraint) using the workbench, but i don't know what the error is. Any help i would appreciate it.
{CREATE TABLE IF NOT EXISTS item (
itemNo CHAR(8),
categId CHAR(8),
sellerId CHAR(6),
itemName VARCHAR(30),
descr VARCHAR(20),
listPrice CHAR(8),
discPrice CHAR(8),
itemComment VARCHAR(30),
CONSTRAINT item_PK PRIMARY KEY(itemNo),
CONSTRAINT item_FK1 FOREIGN KEY(categId) REFERENCES category(categId),
CONSTRAINT item_FK2 FOREIGN KEY(sellerId) REFERENCES feedback(sellerId)
);}
Here are the tables, the first two were created its the item table that im stuck on.
CREATE TABLE department (
departId CHAR(6),
depDesc VARCHAR(20),
CONSTRAINT dep_PK PRIMARY KEY(departId)
);
CREATE TABLE category (
categId CHAR(8),
catDesc VARCHAR(20),
departId VARCHAR(20),
CONSTRAINT cat_PK PRIMARY KEY(categId),
CONSTRAINT cat_FK FOREIGN KEY(departId) REFERENCES department(departId)
);
CREATE TABLE item (
itemNo CHAR(8),
categId CHAR(8),
sellerId CHAR(6),
itemName VARCHAR(30),
descr VARCHAR(20),
listPrice CHAR(8),
discPrice CHAR(8),
itemComment VARCHAR(30),
CONSTRAINT item_PK PRIMARY KEY(itemNo),
CONSTRAINT item_FK FOREIGN KEY(categId) REFERENCES category(categId)
);