Error SQL query: Copy ALTER TABLE `categories` ADD CONSTRAINT `parent category` FOREIGN KEY (`parent_id`) REFERENCES `parents`(`id`) ON DELETE RESTRICT ON UPDATE RESTRICT; MySQL said: Documentation #1215 - Cannot add foreign key constraint code example
Example: create table mysql with foreign key
CREATE TABLE Orders (
OrderID int NOT NULL,
OrderNumber int NOT NULL,
PersonID int,
PRIMARY KEY (OrderID),
FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)
);