это моя таблица стран
create table country(id int auto_increment primary key,
country_name varchar(100),
country_code varchar(10),
provider_country_id varchar(50),
provider_id int);
это моя таблица состояний
create table state(id int primary key auto_increment,
state_name varchar(100),
provider_state_id varchar(50),
provider_id int,
country_id int,
foreign key(country_id) references country(id) on delete set null);
это моя таблица городов
create table city(id int primary key auto_increment,
city_name varchar(100),
provider_city_id varchar(50),
state_id int,
foreign key(state_id) references state(id) on delete set null,
country_id int,
foreign key(country_id) references country(id) on delete set null,
provider_id int);
я создал новый table как
create table new_table
select city.id as cityId, city.provider_city_id as providerCityId, city.city_name as cityName, state.state_name as stateName, country.country_name as countryName, country.country_code as countryCode, state.id as stateId, city.state_id as stateIdFromCity, country.id as countryId, state.country_id as countryIdFromState from city city,state state, country country
where city.state_id = state.id and state.country_id = country.id;
, тогда я также создал индекс как
create index multi_idx on new_table(stateId, stateIdFromCity, countryId, countryIdFromState);
, теперь мне нужно создать триггер для new_table при вставке, удалении, обновлении этих трех таблиц. как это сделать?