MySQL usuń z tabeli dziecięcej, gdy usuniemy wiersze z rodzica
MySQL ON DELETE CASCADE
syntax:
CREATE TABLE Employee (
emp_id int(10) NOT NULL,
...
...
PRIMARY KEY (emp_id)
);
CREATE TABLE Payment (
payment_id int(10) PRIMARY KEY NOT NULL,
emp_id int(10) NOT NULL,
...
...
FOREIGN KEY (emp_id) REFERENCES Employee (emp_id) ON DELETE CASCADE
);
Exuberant Elk