CREATE TABLE `wc_predictions` (
	`id` int NOT NULL AUTO_INCREMENT,
	`user_id` int NOT NULL,
	`top8_team1_id` smallint NULL,
	`top8_team2_id` smallint NULL,
	`top8_team3_id` smallint NULL,
	`top8_team4_id` smallint NULL,
	`top8_team5_id` smallint NULL,
	`top8_team6_id` smallint NULL,
	`top8_team7_id` smallint NULL,
	`top8_team8_id` smallint NULL,
	`champion_team_id` smallint NULL,
	`second_place_team_id` smallint NULL,
	`third_place_team_id` smallint NULL,
	`final_champion_score` tinyint NULL,
	`final_second_place_score` tinyint NULL,
	`top_scorer_id` int NULL,
	`final_goes_to_penalties` varchar(10) NULL,
	`host_team_goes_furthest_id` smallint NULL,
	`total_points` smallint NOT NULL DEFAULT 0,
	`submitted_at` datetime NULL,
	`updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
	PRIMARY KEY (`id` )
);

CREATE TABLE `wc_users` (
	`id` int NOT NULL AUTO_INCREMENT,
	`display_name` varchar(100) NOT NULL,
	`email` varchar(255) NOT NULL,
	`password_hash` varchar(255) NOT NULL,
	`reset_date` datetime NULL,
	`reset_token` varchar(50) NULL,
	`usertype` varchar(50) NULL,
	PRIMARY KEY (`id` )
);

CREATE TABLE `wc_actual_answers` (
	`id` tinyint NOT NULL DEFAULT 1,
	`top8_team1_id` smallint NULL,
	`top8_team2_id` smallint NULL,
	`top8_team3_id` smallint NULL,
	`top8_team4_id` smallint NULL,
	`top8_team5_id` smallint NULL,
	`top8_team6_id` smallint NULL,
	`top8_team7_id` smallint NULL,
	`top8_team8_id` smallint NULL,
	`champion_team_id` smallint NULL,
	`second_place_team_id` smallint NULL,
	`third_place_team_id` smallint NULL,
	`final_champion_score` tinyint NULL,
	`final_second_place_score` tinyint NULL,
	`top_scorer_id` int NULL,
	`final_goes_to_penalties` tinyint NULL,
	`host_team_goes_furthest_id` smallint NULL,
	`updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
	PRIMARY KEY (`id` )
);

CREATE TABLE `wc_top_scorers` (
	`id` int NOT NULL AUTO_INCREMENT,
	`player_name` varchar(100) NOT NULL,
	`team_id` smallint NOT NULL,
	PRIMARY KEY (`id` )
);

CREATE TABLE `wc_questions` (
	`id` tinyint NOT NULL,
	`question_text` varchar(255) NOT NULL,
	PRIMARY KEY (`id` )
);

CREATE TABLE `wc_teams` (
	`id` smallint NOT NULL AUTO_INCREMENT,
	`team_name` varchar(100) NOT NULL,
	`fifa_code` varchar(3) NOT NULL,
	`group_name` varchar(1) NULL,
	`is_host` tinyint NOT NULL DEFAULT 0,
	`flag_url` varchar(255) NOT NULL,
	PRIMARY KEY (`id` )
);


INSERT INTO `wc_predictions` (`id`,`user_id`,`top8_team1_id`,`top8_team2_id`,`top8_team3_id`,`top8_team4_id`,`top8_team5_id`,`top8_team6_id`,`top8_team7_id`,`top8_team8_id`,`champion_team_id`,`second_place_team_id`,`third_place_team_id`,`final_champion_score`,`final_second_place_score`,`top_scorer_id`,`final_goes_to_penalties`,`host_team_goes_furthest_id`,`total_points`,`submitted_at`,`updated_at`) VALUES (15, 1, 9, 37, 17, 21, 29, 33, 46, 45, 33, 37, 45, 2, 1, 2, 'No', 13, 0, NULL, '2026-06-23 07:15:06');
INSERT INTO `wc_predictions` (`id`,`user_id`,`top8_team1_id`,`top8_team2_id`,`top8_team3_id`,`top8_team4_id`,`top8_team5_id`,`top8_team6_id`,`top8_team7_id`,`top8_team8_id`,`champion_team_id`,`second_place_team_id`,`third_place_team_id`,`final_champion_score`,`final_second_place_score`,`top_scorer_id`,`final_goes_to_penalties`,`host_team_goes_furthest_id`,`total_points`,`submitted_at`,`updated_at`) VALUES (18, 3, 34, 46, 9, 27, 11, 42, 20, 35, 37, 39, 4, 2, 1, 7, 'No', 1, 0, NULL, '2026-06-23 09:43:47');
INSERT INTO `wc_predictions` (`id`,`user_id`,`top8_team1_id`,`top8_team2_id`,`top8_team3_id`,`top8_team4_id`,`top8_team5_id`,`top8_team6_id`,`top8_team7_id`,`top8_team8_id`,`champion_team_id`,`second_place_team_id`,`third_place_team_id`,`final_champion_score`,`final_second_place_score`,`top_scorer_id`,`final_goes_to_penalties`,`host_team_goes_furthest_id`,`total_points`,`submitted_at`,`updated_at`) VALUES (19, 4, 9, 39, 39, 25, 5, 5, 25, 42, 46, 4, 20, 2, 1, 4, NULL, 13, 0, NULL, '2026-06-29 13:08:42');

INSERT INTO `wc_users` (`id`,`display_name`,`email`,`password_hash`,`reset_date`,`reset_token`,`usertype`) VALUES (1, 'phprunner', 'kornilov@gmail.com', '$2y$10$NNjnXamqEw4L3pVJrCWXOeuWmRnlWCz7dbQn8DnAda2iIUwLvYI.e', NULL, NULL, 'admin');
INSERT INTO `wc_users` (`id`,`display_name`,`email`,`password_hash`,`reset_date`,`reset_token`,`usertype`) VALUES (3, 'test', 'test@test.com', '$2y$10$UwyR6L/Fwy8JTw1MLtEBJejDe5W3zYruftOZykww91jltLBedPora', NULL, NULL, 'user');
INSERT INTO `wc_users` (`id`,`display_name`,`email`,`password_hash`,`reset_date`,`reset_token`,`usertype`) VALUES (4, 'second', 'test', '$2y$10$NNjnXamqEw4L3pVJrCWXOeuWmRnlWCz7dbQn8DnAda2iIUwLvYI.e', '2026-06-29 13:06:28', NULL, 'user');
INSERT INTO `wc_users` (`id`,`display_name`,`email`,`password_hash`,`reset_date`,`reset_token`,`usertype`) VALUES (7, 'onemore', 'test2', '$2y$10$NNjnXamqEw4L3pVJrCWXOeuWmRnlWCz7dbQn8DnAda2iIUwLvYI.e', NULL, NULL, 'user');
INSERT INTO `wc_users` (`id`,`display_name`,`email`,`password_hash`,`reset_date`,`reset_token`,`usertype`) VALUES (8, 'test3', 'test3@test.com', '$2y$10$Bvie50fXd7rGtMONjNZU4ufAx8mC.mUYKvuUBH1xODSZT6zJlpY4a', NULL, NULL, 'user');

INSERT INTO `wc_actual_answers` (`id`,`top8_team1_id`,`top8_team2_id`,`top8_team3_id`,`top8_team4_id`,`top8_team5_id`,`top8_team6_id`,`top8_team7_id`,`top8_team8_id`,`champion_team_id`,`second_place_team_id`,`third_place_team_id`,`final_champion_score`,`final_second_place_score`,`top_scorer_id`,`final_goes_to_penalties`,`host_team_goes_furthest_id`,`updated_at`) VALUES (1, 29, 37, 45, 33, 10, 36, 25, 8, 29, 37, 45, 1, 0, 15, 0, NULL, '2026-07-21 13:46:39');

INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (6, 'Ayase Ueda', 22);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (11, 'Brian Brobbey', 21);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (8, 'Cody Gakpo', 21);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (4, 'Crysencio Summerville', 21);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (17, 'Cyle Larin', 5);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (18, 'Daichi Kamada', 22);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (1, 'Deniz Undav', 17);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (21, 'Elijah Just', 28);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (14, 'Erling Haaland', 36);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (19, 'Folarin Balogun', 13);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (13, 'Harry Kane', 45);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (20, 'Ismael Saibari', 10);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (10, 'Johan Manzambi', 8);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (3, 'Jonathan David', 5);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (22, 'Kai Havertz', 17);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (15, 'Kylian Mbappé', 33);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (2, 'Lionel Messi', 37);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (16, 'Matheus Cunha', 9);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (7, 'Maxi Araujo', 32);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (5, 'Mikel Oyarzabal', 29);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (9, 'Vinicius Jr.', 9);
INSERT INTO `wc_top_scorers` (`id`,`player_name`,`team_id`) VALUES (12, 'Yasin Ayari', 23);

INSERT INTO `wc_questions` (`id`,`question_text`) VALUES (1, 'Choose 8 teams that will reach the quarterfinals.');
INSERT INTO `wc_questions` (`id`,`question_text`) VALUES (2, 'Who will win the World Cup?');
INSERT INTO `wc_questions` (`id`,`question_text`) VALUES (3, 'Who will finish second?');
INSERT INTO `wc_questions` (`id`,`question_text`) VALUES (4, 'Who will finish third?');
INSERT INTO `wc_questions` (`id`,`question_text`) VALUES (5, 'What will be the final score?');
INSERT INTO `wc_questions` (`id`,`question_text`) VALUES (6, 'Who will be the tournament top scorer?');
INSERT INTO `wc_questions` (`id`,`question_text`) VALUES (7, 'Will the final go to penalties?');
INSERT INTO `wc_questions` (`id`,`question_text`) VALUES (8, 'Which host team will go the furthest?');

INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (1, 'Mexico', 'MEX', 'A', 1, 'flags/mexico.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (2, 'South Africa', 'RSA', 'A', 0, 'flags/south_africa.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (3, 'South Korea', 'KOR', 'A', 0, 'flags/south_korea.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (4, 'Czechia', 'CZE', 'A', 0, 'flags/czechia.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (5, 'Canada', 'CAN', 'B', 1, 'flags/canada.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (6, 'Bosnia and Herzegovina', 'BIH', 'B', 0, 'flags/bosnia_and_herzegovina.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (7, 'Qatar', 'QAT', 'B', 0, 'flags/qatar.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (8, 'Switzerland', 'SUI', 'B', 0, 'flags/switzerland.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (9, 'Brazil', 'BRA', 'C', 0, 'flags/brazil.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (10, 'Morocco', 'MAR', 'C', 0, 'flags/morocco.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (11, 'Haiti', 'HTI', 'C', 0, 'flags/haiti.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (12, 'Scotland', 'SCO', 'C', 0, 'flags/scotland.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (13, 'United States', 'USA', 'D', 1, 'flags/united_states.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (14, 'Paraguay', 'PAR', 'D', 0, 'flags/paraguay.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (15, 'Australia', 'AUS', 'D', 0, 'flags/australia.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (16, 'Turkey', 'TUR', 'D', 0, 'flags/turkey.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (17, 'Germany', 'GER', 'E', 0, 'flags/germany.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (18, 'Curaçao', 'CUW', 'E', 0, 'flags/curacao.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (19, 'Ivory Coast', 'CIV', 'E', 0, 'flags/ivory_coast.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (20, 'Ecuador', 'ECU', 'E', 0, 'flags/ecuador.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (21, 'Netherlands', 'NED', 'F', 0, 'flags/netherlands.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (22, 'Japan', 'JPN', 'F', 0, 'flags/japan.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (23, 'Sweden', 'SWE', 'F', 0, 'flags/sweden.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (24, 'Tunisia', 'TUN', 'F', 0, 'flags/tunisia.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (25, 'Belgium', 'BEL', 'G', 0, 'flags/belgium.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (26, 'Egypt', 'EGY', 'G', 0, 'flags/egypt.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (27, 'Iran', 'IRI', 'G', 0, 'flags/iran.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (28, 'New Zealand', 'NZL', 'G', 0, 'flags/new_zealand.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (29, 'Spain', 'ESP', 'H', 0, 'flags/spain.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (30, 'Cape Verde', 'CPV', 'H', 0, 'flags/cape_verde.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (31, 'Saudi Arabia', 'KSA', 'H', 0, 'flags/saudi_arabia.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (32, 'Uruguay', 'URU', 'H', 0, 'flags/uruguay.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (33, 'France', 'FRA', 'I', 0, 'flags/france.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (34, 'Senegal', 'SEN', 'I', 0, 'flags/senegal.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (35, 'Iraq', 'IRQ', 'I', 0, 'flags/iraq.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (36, 'Norway', 'NOR', 'I', 0, 'flags/norway.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (37, 'Argentina', 'ARG', 'J', 0, 'flags/argentina.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (38, 'Algeria', 'DZA', 'J', 0, 'flags/algeria.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (39, 'Austria', 'AUT', 'J', 0, 'flags/austria.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (40, 'Jordan', 'JOR', 'J', 0, 'flags/jordan.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (41, 'Portugal', 'POR', 'K', 0, 'flags/portugal.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (42, 'DR Congo', 'COD', 'K', 0, 'flags/dr_congo.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (43, 'Uzbekistan', 'UZB', 'K', 0, 'flags/uzbekistan.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (44, 'Colombia', 'COL', 'K', 0, 'flags/colombia.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (45, 'England', 'ENG', 'L', 0, 'flags/england.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (46, 'Croatia', 'CRO', 'L', 0, 'flags/croatia.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (47, 'Ghana', 'GHA', 'L', 0, 'flags/ghana.png');
INSERT INTO `wc_teams` (`id`,`team_name`,`fifa_code`,`group_name`,`is_host`,`flag_url`) VALUES (48, 'Panama', 'PAN', 'L', 0, 'flags/panama.png');


ALTER TABLE `wc_predictions`
ADD FOREIGN KEY ( `champion_team_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_predictions`
ADD FOREIGN KEY ( `host_team_goes_furthest_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_predictions`
ADD FOREIGN KEY ( `second_place_team_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_predictions`
ADD FOREIGN KEY ( `third_place_team_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_predictions`
ADD FOREIGN KEY ( `top8_team1_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_predictions`
ADD FOREIGN KEY ( `top8_team2_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_predictions`
ADD FOREIGN KEY ( `top8_team3_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_predictions`
ADD FOREIGN KEY ( `top8_team4_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_predictions`
ADD FOREIGN KEY ( `top8_team5_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_predictions`
ADD FOREIGN KEY ( `top8_team6_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_predictions`
ADD FOREIGN KEY ( `top8_team7_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_predictions`
ADD FOREIGN KEY ( `top8_team8_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_predictions`
ADD FOREIGN KEY ( `top_scorer_id` )
REFERENCES `wc_top_scorers` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_predictions`
ADD FOREIGN KEY ( `user_id` )
REFERENCES `wc_users` ( `id` )
ON UPDATE NO ACTION
ON DELETE CASCADE
;

ALTER TABLE `wc_actual_answers`
ADD FOREIGN KEY ( `champion_team_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_actual_answers`
ADD FOREIGN KEY ( `host_team_goes_furthest_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_actual_answers`
ADD FOREIGN KEY ( `second_place_team_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_actual_answers`
ADD FOREIGN KEY ( `third_place_team_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_actual_answers`
ADD FOREIGN KEY ( `top8_team1_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_actual_answers`
ADD FOREIGN KEY ( `top8_team2_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_actual_answers`
ADD FOREIGN KEY ( `top8_team3_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_actual_answers`
ADD FOREIGN KEY ( `top8_team4_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_actual_answers`
ADD FOREIGN KEY ( `top8_team5_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_actual_answers`
ADD FOREIGN KEY ( `top8_team6_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_actual_answers`
ADD FOREIGN KEY ( `top8_team7_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_actual_answers`
ADD FOREIGN KEY ( `top8_team8_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;
ALTER TABLE `wc_actual_answers`
ADD FOREIGN KEY ( `top_scorer_id` )
REFERENCES `wc_top_scorers` ( `id` )
ON UPDATE NO ACTION
ON DELETE SET NULL
;

ALTER TABLE `wc_top_scorers`
ADD FOREIGN KEY ( `team_id` )
REFERENCES `wc_teams` ( `id` )
ON UPDATE NO ACTION
ON DELETE CASCADE
;
