Skip to content

Instantly share code, notes, and snippets.

@betulaydinturkk
Created June 22, 2024 22:11
Show Gist options
  • Save betulaydinturkk/b7a2edebe7fe2c37f384f721c2e4c740 to your computer and use it in GitHub Desktop.
Save betulaydinturkk/b7a2edebe7fe2c37f384f721c2e4c740 to your computer and use it in GitHub Desktop.
CREATE TABLE Team (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
country VARCHAR(100) NOT NULL
);
CREATE TABLE Car (
id INT AUTO_INCREMENT PRIMARY KEY,
carNumber VARCHAR(50) NOT NULL,
weight DECIMAL(10, 2),
maxSpeed INT,
team_id INT,
FOREIGN KEY (team_id) REFERENCES Team(id)
);
CREATE TABLE Pilot (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
birthDate DATE,
country VARCHAR(100),
car_id INT,
FOREIGN KEY (car_id) REFERENCES Car(id)
);
CREATE TABLE Circuit (
id INT AUTO_INCREMENT PRIMARY KEY,
city VARCHAR(100) NOT NULL,
country VARCHAR(100) NOT NULL,
distance DECIMAL(10, 2)
);
CREATE TABLE Race (
id INT AUTO_INCREMENT PRIMARY KEY,
date DATE NOT NULL,
numberOfLaps INT,
circuit_id INT,
FOREIGN KEY (circuit_id) REFERENCES Circuit(id)
);
CREATE TABLE Participation (
id INT AUTO_INCREMENT PRIMARY KEY,
pilot_id INT,
race_id INT,
startingPosition INT,
finalPosition INT,
FOREIGN KEY (pilot_id) REFERENCES Pilot(id),
FOREIGN KEY (race_id) REFERENCES Race(id)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment