To run sucessfuly this project you need to insert your database name, username and password and create the tables like this: And you need to insert the teams manually in your database. If doesn't work, make sure that ypu have JDBC library in your project
-- phpMyAdmin SQL Dump -- version 5.2.0 -- https://www.phpmyadmin.net/
-- Host: 127.0.0.1 -- Tempo de geração: 24-Ago-2023 às 23:03 -- Versão do servidor: 10.4.27-MariaDB -- versão do PHP: 8.2.0
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; START TRANSACTION; SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT /; /!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS /; /!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION /; /!40101 SET NAMES utf8mb4 */;
CREATE TABLE athletes
(
id
int(11) NOT NULL,
athlete_name
varchar(100) NOT NULL,
athlete_number
int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE TABLE athletes_has_teams
(
athletes_id
int(11) NOT NULL,
teams_id
int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE TABLE teams
(
id
int(11) NOT NULL,
team_name
varchar(100) NOT NULL,
team_gender
varchar(45) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE TABLE trainers
(
id
int(11) NOT NULL,
name
varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE TABLE trainers_has_teams
(
trainers_id
int(11) NOT NULL,
teams_id
int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
ALTER TABLE athletes
ADD PRIMARY KEY (id
);
ALTER TABLE athletes_has_teams
ADD PRIMARY KEY (athletes_id
,teams_id
),
ADD KEY fk_athletes_has_teams_teams1_idx
(teams_id
),
ADD KEY fk_athletes_has_teams_athletes_idx
(athletes_id
);
ALTER TABLE teams
ADD PRIMARY KEY (id
);
ALTER TABLE trainers
ADD PRIMARY KEY (id
);
ALTER TABLE trainers_has_teams
ADD PRIMARY KEY (trainers_id
,teams_id
),
ADD KEY fk_trainers_has_teams_teams_idx
(teams_id
);
ALTER TABLE athletes
MODIFY id
int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;
ALTER TABLE teams
MODIFY id
int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
ALTER TABLE trainers
MODIFY id
int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
ALTER TABLE athletes_has_teams
ADD CONSTRAINT fk_athletes_has_teams_athletes
FOREIGN KEY (athletes_id
) REFERENCES athletes
(id
),
ADD CONSTRAINT fk_athletes_has_teams_teams1
FOREIGN KEY (teams_id
) REFERENCES teams
(id
);
ALTER TABLE trainers_has_teams
ADD CONSTRAINT fk_trainers_has_teams_teams
FOREIGN KEY (teams_id
) REFERENCES teams
(id
),
ADD CONSTRAINT fk_trainers_has_teams_trainers
FOREIGN KEY (trainers_id
) REFERENCES trainers
(id
);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT /; /!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS /; /!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;