はい、方法があります。外部キーのカスケード削除については、mysql のドキュメントを確認してください。
例:
CREATE TABLE parent (id INT NOT NULL,
PRIMARY KEY (id)
) ENGINE=INNODB;
CREATE TABLE child (id INT, parent_id INT,
INDEX par_ind (parent_id),
FOREIGN KEY (parent_id) REFERENCES parent(id)
ON DELETE CASCADE
) ENGINE=INNODB;
Insert into parent set id=1;
Insert into parent set id=2;
Insert into parent set id=3;
Insert into child set id=1, parent_id=1;
Insert into child set id=2, parent_id=1;
select * from parent;
select * from child;
delete from parent where id=1;
select * from parent;
select * from child;
ID
1
2
3
Record Count: 3; Execution Time: 0ms View Execution Plan
ID PARENT_ID
1 1
2 1
Record Count: 2; Execution Time: 0ms View Execution Plan
Record Count: 0; Execution Time: 1ms
ID
2
3
Record Count: 2; Execution Time: 0ms View Execution Plan
Record Count: 0; Execution Time: 0ms