USE test;
DROP TABLE IF EXISTS test2;
DROP TABLE IF EXISTS test1;

CREATE TABLE test1 (
	id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
	value CHAR(1),
	PRIMARY KEY ( id )
) ENGINE=InnoDB WITH SYSTEM VERSIONING;
CREATE TABLE test2 (
	parent TINYINT UNSIGNED NOT NULL,
	FOREIGN KEY ( parent ) REFERENCES test1 ( id ) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB WITH SYSTEM VERSIONING;

INSERT INTO test1 ( value ) VALUES
	( 'A' ),	( 'B' );

INSERT INTO test2 VALUES
	( 1 ),
	( 2 );

SELECT *
FROM test2
LEFT JOIN test1 ON test2.parent = test1.id;

DELETE FROM test1 WHERE id = 1;
DELETE test1 FROM test1 WHERE id = 2;

SELECT *
FROM test2
LEFT JOIN test1 ON test2.parent = test1.id;
