Hello. The problem is actually in the title. There are three labels, with a 1 to many dependency:
apps.id
Ver─versions.app_id
T─translations.app_id
When rows from the bottom two tables are added or removed, the entry in the corresponding field of the apps table changes.
trigger (for example, translations after delete )
BEGIN UPDATE apps SET translations_count = translations_count - 1 WHERE apps.id = OLD.app_id LIMIT 1; END
trigger ( apps before delete )
BEGIN DELETE FROM app_info_translations WHERE app_info_translations.app_id = OLD.id; DELETE FROM app_versions WHERE app_versions.app_id = OLD.id; END
When I delete a record from apps, the trigger deletes the records from the dependent tables, which in turn try to modify this same record in apps (and then an error occurs).
Question : how to rebuild the base, leaving the same functionality, but get rid of the error? Those. with the ability to delete the entry from the apps
ps triggers are added to store statistics in the records of the apps table, instead of constantly selecting different information from a heap of tables.