Mysql: Should I use AFTER INSERT triggers to populate reference / join tables?


Could the use of MySQL triggers cause difficulties in the subsequent development of the code? Should I stick to the following relationships in the code instead of the DB?

I have the following tables:

CREATE TABLE `models` (
`id` int (11) NOT NULL AUTO_INCREMENT,
`user` varchar (64) NOT NULL
Primary key ("id")
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_unicode_ci ";
CREATE TABLE `texts_model` (
`id` int (11) NOT NULL AUTO_INCREMENT,
`text` varchar (1024) NOT NULL,
PRIMARY KEY (ID)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_unicode_ci ";
CREATE TABLE `model_text_link` (
`id` int (11) NOT NULL AUTO_INCREMENT,
`model_id` int (11) NOT NULL,
`text_id` int (11) NOT NULL,
`last_used` DATETIME NULL,
Primary key ("id"),
KEY `model_id` (` model_id`),
KEY `text_id` (` text_id`),
CONSTRAINT `model_text_link_ibfk_1` FOREIGN KEY (` model_id`) REFERENCES `models` (` id`) ON DELETE CASCADE,
CONSTRAINT `model_text_link_ibfk_2` FOREIGN KEY (` text_id`) REFERENCES `texts_model` (` id`) ON DELETE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_unicode_ci ";

And the following triggers were used to get the model_text_link Table:

CREATE TRIGGER model_AI AFTER INSERTING MODELS FOR EACH SERIES
BEGIN
INSERT INTO model_text_link (model_id, text_id) SELECT NEW.id, id as text_id FROM texts_model;
THE END;
CREATE TRIGGER texts_model_AI AFTER INSERT ON texts_model FOR EACH SERIES
BEGIN
INSERT INTO model_text_link (model_id, text_id) SELECT id, NEW.id FROM models;
THE END;

Everyone user of the user Table must have a link to all text Rows in the texts Table so that I can use the texts for all users, but one last used Timestamp for everyone text Per user in that user_text_link Table.

With the current code model_text_link Records are deleted / inserted text or model delete / insert

But most of the frameworks I've seen (for example, Symfony / Doctrine) handle this logic in the framework without using the MySQL triggers, and rely on FOREIGN KEYS to clean up.