I created a table called 'publicaciones' in the database called 'curso'. This table has a foreign key column that references to the id column of another table called 'usuarios'. When I try to insert a row into the 'publicaciones' table I got the Error Code 1452 which says 'Cannot add or update a child row; a foreign key contrait fails'.
TABLE publicaciones
CREATE TABLE curso.publicaciones (
    id int(11) NOT NULL AUTO_INCREMENT,
    autor_id int(11) NOT NULL,
    titulo varchar(150) NOT NULL,
    texto text NOT NULL,
    PRIMARY KEY(id),
    FOREIGN KEY (autor_id) REFERENCES curso.usuarios(id) ON DELETE CASCADE
);
INSERT query
INSERT INTO curso.publicaciones (
    autor_id,
    titulo,
    texto
) VALUES (
    '1',
    'Clean Code',
    'You should be a clean coder. Thanks.'
);
I tried adding the constraint "ON DELETE CASCADE", but it does not work.
 
     
    