Propozycja którą tłumaczyłem
4 tabele
CREATE TABLE `match` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`team_A` int(11) NOT NULL,
`team_B` int(11) NOT NULL,
`goals_A` int(11) NOT NULL,
`goals_B` int(11) NOT NULL,
`is_done` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_match_team1_idx` (`team_A`),
KEY `fk_match_team2_idx` (`team_B`),
CONSTRAINT `fk_match_team1` FOREIGN KEY (`team_A`) REFERENCES `team` (`idt`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_match_team2` FOREIGN KEY (`team_B`) REFERENCES `team` (`idt`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8
CREATE TABLE `player` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`surname` varchar(45) NOT NULL,
`team_idt` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `fk_player_team_idx` (`team_idt`),
CONSTRAINT `fk_player_team` FOREIGN KEY (`team_idt`) REFERENCES `team` (`idt`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8
CREATE TABLE `team` (
`idt` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`idt`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8
CREATE TABLE `team_has_player` (
`team_idt` int(11) NOT NULL,
`player_id` int(11) NOT NULL,
`match_id` int(11) NOT NULL,
PRIMARY KEY (`team_idt`,`player_id`),
KEY `fk_team_has_player_player1_idx` (`player_id`),
KEY `fk_team_has_player_team1_idx` (`team_idt`),
KEY `fk_team_has_player_match1_idx` (`match_id`),
CONSTRAINT `fk_team_has_player_team1` FOREIGN KEY (`team_idt`) REFERENCES `team` (`idt`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_team_has_player_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_team_has_player_match1` FOREIGN KEY (`match_id`) REFERENCES `match` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8
Struktura, pod warunkiem odpowiedniego umieszczania danych pozwala na wyciągnięcie wszystkiego tak jak chciałeś. Wykonane tak na szybkości, czegoś dla Ciebie ważnego na pewno brakuje, ale funkcjonuje i zdaje się działać poprawnie.
Zapewne są lepsze metody.
~kpt_lucek