I have a problem with adding constraint foreign key to my table.
Below is a code I setup in my base:
CREATE TABLE IF NOT EXISTS `basename`.`Category_News` (
`Id_Category` INT NOT NULL AUTO_INCREMENT,
`Id_Category_Parent` INT NULL,
`Name` VARCHAR(50) NOT NULL,
`Desc` VARCHAR(255) NOT NULL,
`Published` ENUM('0','1') NOT NULL DEFAULT '0',
PRIMARY KEY (`Id_Category`),
INDEX `fk_Category_Newsa_idx` (`Id_Category_Parent` ASC),
CONSTRAINT `fk_Category_News`
FOREIGN KEY (`Id_Category_Parent`)
REFERENCES `basename`.`Category_News` (`Id_Category`)
) ENGINE = InnoDB;
I changed base engine from MyISAM to InnoDB but...
Can someone tell me, why when I insert new row for e.g. with atribute Id_Category_Parent = 8 there are no error even if category with this id not exists ?