alter table t_a_forum add

    FOREIGN KEY (i_parent_forum_id) REFERENCES t_a_forum (i_forum_id) ON DELETE NO ACTION ON UPDATE CASCADE;

alter table t_a_forum add

    FOREIGN KEY (t_style) REFERENCES t_e_style (t_style) ON DELETE NO ACTION ON UPDATE cascade;

alter table t_a_forum add

    FOREIGN KEY (i_last_post_id) REFERENCES t_s_post (i_post_id) ON DELETE SET NULL ON UPDATE CASCADE;




alter table t_a_group add

    foreign key(i_clan_forum_id) references t_a_forum on delete no action on update CASCADE;



alter TABLE t_a_match add

    FOREIGN KEY (i_match_cup_id) REFERENCES t_r_match_cup (i_match_cup_id) ON DELETE NO ACTION ON UPDATE CASCADE;

alter TABLE t_a_match add

    FOREIGN KEY (i_topic_id) REFERENCES t_s_topic (i_topic_id) ON DELETE NO ACTION ON UPDATE CASCADE;

alter TABLE t_a_match add

    FOREIGN KEY (i_team_id) REFERENCES t_a_team (i_team_id) ON DELETE CASCADE ON UPDATE CASCADE;


alter table t_a_server add

  FOREIGN KEY (t_ip) REFERENCES t_a_machine(t_ip) ON DELETE NO ACTION ON UPDATE CASCADE;

alter table t_a_server add

  FOREIGN KEY (t_qstat) REFERENCES t_e_qstat (t_qstat) ON DELETE NO ACTION ON UPDATE CASCADE;

alter table t_a_server add

  FOREIGN KEY (t_xfire) REFERENCES t_e_xfire (t_xfire) ON DELETE NO ACTION ON UPDATE CASCADE;

alter table t_a_server add

  FOREIGN KEY (t_game) REFERENCES t_e_game (t_game) ON DELETE SET NULL ON UPDATE CASCADE;

alter table t_a_server add
    foreign key(i_user_admin_id) references t_a_user (i_user_id) on delete set null on update cascade;
alter table t_a_server add
    foreign key(i_group_id) references t_a_group (i_group_id) on delete set null on update cascade;

alter table t_a_ts_server add
    foreign key(i_group_id) references t_a_group (i_group_id) on delete set null on update cascade;

alter table t_a_team add

    FOREIGN KEY (t_game) REFERENCES t_e_game (t_game) ON DELETE NO ACTION ON UPDATE CASCADE;

alter table t_a_team add

    FOREIGN KEY (i_group_id) REFERENCES t_a_group (i_group_id) ON DELETE CASCADE ON UPDATE CASCADE;

alter table t_a_team add

    FOREIGN KEY (i_war_arranger_id) REFERENCES t_a_user (i_user_id) ON DELETE SET NULL ON UPDATE CASCADE;


alter table t_a_user add

    FOREIGN KEY (t_lang) REFERENCES t_e_lang (t_lang) ON DELETE NO ACTION ON UPDATE CASCADE;

alter table t_a_user add

    FOREIGN KEY (t_result_view) REFERENCES t_e_result_view (t_result_view) ON DELETE NO ACTION ON UPDATE CASCADE;

alter table t_a_user add

    FOREIGN KEY (i_avatar_file_id) REFERENCES t_a_file (i_file_id) ON DELETE NO ACTION ON UPDATE CASCADE;

alter table t_a_user add

    FOREIGN KEY (i_guestbook_topic_id) REFERENCES t_s_topic (i_topic_id) ON DELETE NO ACTION ON UPDATE CASCADE;

alter table t_a_user add

    foreign key(i_pm_forum_id) references t_a_forum on delete no action on update cascade;

alter table t_a_user add

    FOREIGN KEY (i_browsing_forum_id) REFERENCES t_a_forum (i_forum_id) ON DELETE SET NULL ON UPDATE CASCADE;

alter table t_a_user add

    FOREIGN KEY (i_browsing_topic_id) REFERENCES t_s_topic (i_topic_id) ON DELETE SET NULL ON UPDATE CASCADE;


alter table t_e_style add

  FOREIGN KEY (t_post_style) REFERENCES t_e_style (t_style) ON DELETE NO ACTION ON UPDATE cascade;

alter table t_e_style add

  FOREIGN KEY (t_style_level) REFERENCES t_e_style_level (t_style_level) ON DELETE NO ACTION ON UPDATE CASCADE;

alter table t_e_style add

  FOREIGN KEY (t_style_type) REFERENCES t_e_style_type (t_style_type) ON DELETE NO ACTION ON UPDATE CASCADE;


alter table t_p_forum_topic_style add

  FOREIGN KEY (t_forum_style) REFERENCES t_e_style (t_style) ON DELETE NO ACTION ON UPDATE CASCADE;

alter table t_p_forum_topic_style add

  FOREIGN KEY (t_topic_style) REFERENCES t_e_style (t_style) ON DELETE NO ACTION ON UPDATE CASCADE;


alter TABLE t_p_group_forum_access add

  FOREIGN KEY (i_group_id) REFERENCES t_a_group (i_group_id) ON DELETE CASCADE ON UPDATE CASCADE;

alter table t_p_group_forum_access add

    FOREIGN KEY (i_forum_id) REFERENCES t_a_forum (i_forum_id) ON DELETE CASCADE ON UPDATE CASCADE;



alter TABLE t_p_group_section add

    FOREIGN KEY (i_group_id) REFERENCES t_a_group (i_group_id) ON DELETE CASCADE ON UPDATE CASCADE;

alter TABLE t_p_group_section add

    FOREIGN KEY (i_section_id) REFERENCES t_a_section (i_section_id) ON DELETE CASCADE ON UPDATE CASCADE;


alter table t_p_match_player add

    FOREIGN KEY (i_match_id) REFERENCES t_a_match (i_match_id) ON DELETE CASCADE ON UPDATE CASCADE;

alter table t_p_match_player add

    FOREIGN KEY (i_player_id) REFERENCES t_p_player (i_player_id) ON DELETE NO ACTION ON UPDATE CASCADE;

alter table t_p_match_player add

    FOREIGN KEY (t_match_player_status) REFERENCES t_e_match_player_status (t_match_player_status) ON DELETE NO ACTION ON UPDATE CASCADE;



alter table t_p_player add

    FOREIGN KEY (t_game) REFERENCES t_e_game (t_game) ON DELETE NO ACTION ON UPDATE CASCADE;

alter table t_p_player add

    FOREIGN KEY (i_user_id) REFERENCES t_a_user (i_user_id) ON DELETE CASCADE ON UPDATE CASCADE;


alter TABLE t_p_team_player add

    FOREIGN KEY (i_team_id) REFERENCES t_a_team (i_team_id) ON DELETE CASCADE ON UPDATE CASCADE;

alter TABLE t_p_team_player add

    FOREIGN KEY (i_player_id) REFERENCES t_p_player (i_player_id) ON DELETE CASCADE ON UPDATE CASCADE;


alter table t_p_user_forum_access add

    FOREIGN KEY (i_user_id) REFERENCES t_a_user (i_user_id) ON DELETE CASCADE ON UPDATE CASCADE;

alter table t_p_user_forum_access add

    FOREIGN KEY (i_forum_id) REFERENCES t_a_forum (i_forum_id) ON DELETE CASCADE ON UPDATE CASCADE;


alter table t_p_user_forum_ignore add

    FOREIGN KEY (i_forum_id) REFERENCES t_a_forum (i_forum_id) ON DELETE CASCADE ON UPDATE CASCADE;

alter table t_p_user_forum_ignore add

    FOREIGN KEY (i_user_id) REFERENCES t_a_user (i_user_id) ON DELETE CASCADE ON UPDATE CASCADE;


alter table t_p_user_forum_join add

    FOREIGN KEY (i_forum_id) REFERENCES t_a_forum (i_forum_id) ON DELETE CASCADE ON UPDATE CASCADE;

alter table t_p_user_forum_join add

    FOREIGN KEY (i_user_id) REFERENCES t_a_user (i_user_id) ON DELETE CASCADE ON UPDATE CASCADE;


alter TABLE t_p_user_group add

  FOREIGN KEY (i_user_id) REFERENCES t_a_user (i_user_id) ON DELETE CASCADE ON UPDATE CASCADE;

alter TABLE t_p_user_group add

  FOREIGN KEY (i_group_id) REFERENCES t_a_group (i_group_id) ON DELETE CASCADE ON UPDATE CASCADE;


alter TABLE t_p_user_section add

  FOREIGN KEY (i_user_id) REFERENCES t_a_user (i_user_id) ON DELETE CASCADE ON UPDATE CASCADE;

alter TABLE t_p_user_section add

  FOREIGN KEY (i_section_id) REFERENCES t_a_section (i_section_id) ON DELETE CASCADE ON UPDATE CASCADE;


alter TABLE t_p_user_topic  add

  FOREIGN KEY (i_topic_id) REFERENCES t_s_topic (i_topic_id) ON DELETE CASCADE ON UPDATE CASCADE;

alter TABLE t_p_user_topic  add

  FOREIGN KEY (i_user_id) REFERENCES t_a_user (i_user_id) ON DELETE CASCADE ON UPDATE CASCADE;

alter TABLE t_p_user_topic  add

  FOREIGN KEY (i_last_read_post_id) REFERENCES t_s_post (i_post_id) ON DELETE NO ACTION ON UPDATE CASCADE;


alter TABLE t_p_user_topic_access add

    FOREIGN KEY (i_topic_id) REFERENCES t_s_topic (i_topic_id) ON DELETE CASCADE ON UPDATE CASCADE;

alter TABLE t_p_user_topic_access add

    FOREIGN KEY (i_user_id) REFERENCES t_a_user (i_user_id) ON DELETE CASCADE ON UPDATE CASCADE;


alter table t_r_match_cup add

    FOREIGN KEY (t_game) REFERENCES t_e_game (t_game) ON DELETE NO ACTION ON UPDATE CASCADE;


alter TABLE t_s_post add

    FOREIGN KEY (i_topic_id) REFERENCES t_s_topic (i_topic_id) ON DELETE CASCADE ON UPDATE CASCADE;

alter TABLE t_s_post add

  FOREIGN KEY (t_style) REFERENCES t_e_style (t_style) ON DELETE NO ACTION ON UPDATE CASCADE;

alter TABLE t_s_post add

  FOREIGN KEY (i_user_id) REFERENCES t_a_user (i_user_id) ON DELETE NO ACTION ON UPDATE CASCADE;

alter TABLE t_s_post add

  FOREIGN KEY (i_mod_att_user_id) REFERENCES t_a_user (i_user_id) ON DELETE NO ACTION ON UPDATE CASCADE;

alter TABLE t_s_post add

  FOREIGN KEY (i_post_reply_id) REFERENCES t_s_post(i_post_id) ON DELETE SET NULL ON UPDATE CASCADE;

alter TABLE t_s_post add

  FOREIGN KEY (i_edit_user_id) REFERENCES t_a_user(i_user_id) on delete no action on update cascade;


alter TABLE t_s_post_attach add

    FOREIGN KEY (i_post_id) REFERENCES t_s_post (i_post_id) ON DELETE CASCADE ON UPDATE CASCADE;

alter TABLE t_s_post_attach add

    FOREIGN KEY (i_file_id) REFERENCES t_a_file (i_file_id) ON DELETE CASCADE ON UPDATE CASCADE;


alter table t_s_topic add

    FOREIGN KEY (i_forum_id) REFERENCES t_a_forum (i_forum_id) ON DELETE CASCADE ON UPDATE CASCADE;

alter table t_s_topic add

    FOREIGN KEY (t_style) REFERENCES t_e_style (t_style) ON DELETE NO ACTION ON UPDATE CASCADE;

alter table t_s_topic add

    FOREIGN KEY (i_user_id) REFERENCES t_a_user (i_user_id) ON DELETE NO ACTION ON UPDATE CASCADE;

alter table t_s_topic add

    FOREIGN KEY (i_last_post_id) REFERENCES t_s_post (i_post_id) ON DELETE SET NULL ON UPDATE CASCADE;


alter table t_s_topic_hit add

    FOREIGN KEY (i_topic_id) references t_s_topic(i_topic_id) on delete cascade on update cascade;
alter table t_s_topic_hit add

    FOREIGN KEY (i_user_id) references t_a_user(i_user_id) on delete cascade on update cascade;


alter table t_s_user_feed add

    FOREIGN KEY (i_user_id) REFERENCES t_a_user (i_user_id) ON DELETE CASCADE ON UPDATE CASCADE;


alter table t_s_user_forum_bmk add

    FOREIGN KEY (i_user_id) REFERENCES t_a_user (i_user_id) ON DELETE CASCADE ON UPDATE CASCADE;

alter table t_s_user_forum_bmk add

    FOREIGN KEY (i_forum_id) REFERENCES t_a_forum (i_forum_id) ON DELETE CASCADE ON UPDATE CASCADE;


alter table t_s_user_login add

    FOREIGN KEY (i_user_id) references t_a_user(i_user_id) on delete cascade on update cascade;