Suppose I've the next schema:

CREATE TABLE `users` (
  `id` int(10) unsigned auto_increment,
  `historyId` varchar(255),
  PRIMARY KEY  (`id`)
);

CREATE TABLE `histories` (
  `id` int(10) unsigned auto_increment,
  `history` TEXT,
  PRIMARY KEY  (`id`)
);

A Person only ever has one History, and the objective of not getting histories indicate customers is the fact that a number of other tables (not pointed out within this schema) also provide histories.

What is the easiest way to really make it to ensure that removing a person will even remove its History?

If User-histories it is a 1-1 relation place the the constraint within the customers table and never within the 'hisories' one

I do not think use a foreign answer to cascade removes here, since the data types don't match. You've VARCHAR(255) in a single table, and INT(10) within the other. (What's going on with this?)

I think you will need to use whether trigger or perhaps a saved procedure, neither which is entirely acceptable. Triggers are theoretically the most secure, for the reason that client code can't sneak around them. (Client code could just avoid calling a saved procedure.) But you will find APIs that don't activate MySQL triggers.

MySQL triggers are triggered by SQL claims only. They aren't triggered by alterations in tables produced by APIs that don't transmit SQL claims towards the MySQL Server

u may use trigger such as this

delimiter $$

create trigger dependet_destroy

after remove on users

for every row

begin

remove from histories where id=old.historyId

finish$$

delimiter