PRAGMA foreign_keys = ON;

PRAGMA writable_schema = 1;
DELETE FROM sqlite_master WHERE type IN ("table", "index", "trigger");
PRAGMA writable_schema = 0;
VACUUM;

CREATE TABLE "constructorResults" (
"constructorResultsId" INT,
"raceId" INT,
"constructorId" INT,
PRIMARY KEY ("constructorResultsId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("constructorId") REFERENCES "constructors"("constructorId")
);

CREATE TABLE "constructorStandings" (
"constructorStandingsId" INT,
"points" FLOAT,
PRIMARY KEY ("constructorStandingsId")
);

CREATE TABLE "circuits" (
"circuitId" INT UNIQUE,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" FLOAT,
"lng" FLOAT,
PRIMARY KEY ("circuitId")
);

CREATE TABLE "constructors" (
"constructorId" INT UNIQUE,
"name" TEXT,
"nationality" TEXT,
PRIMARY KEY ("constructorId")
);

CREATE TABLE "races" (
"raceId" INT UNIQUE,
"circuitId" INT,
"name" TEXT,
PRIMARY KEY ("raceId"),
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
);



INSERT INTO "circuits" VALUES ("1", "Albert Park Grand Prix Circuit", "Melbourne", "Australia", "-37.8497", "144.968");
INSERT INTO "circuits" VALUES ("2", "Sepang International Circuit", "Kuala Lumpur", "Malaysia", "2.76083", "101.738");
INSERT INTO "circuits" VALUES ("3", "Bahrain International Circuit", "Sakhir", "Bahrain", "26.0325", "50.5106");
INSERT INTO "circuits" VALUES ("4", "Circuit de Barcelona-Catalunya", "Montmeló", "Spain", "41.57", "2.26111");
INSERT INTO "circuits" VALUES ("5", "Circuit de Monaco", "Monte Carlo", "Monaco", "43.7347", "7.42056");
INSERT INTO "circuits" VALUES ("6", "Circuit Gilles Villeneuve", "Montreal", "Canada", "45.5272", "-73.5228");
INSERT INTO "circuits" VALUES ("7", "Silverstone Circuit", "Silverstone", "UK", "52.0786", "-1.01694");
INSERT INTO "circuits" VALUES ("8", "Hockenheimring", "Hockenheim", "Germany", "49.3278", "8.56583");
INSERT INTO "circuits" VALUES ("9", "Hungaroring", "Mogyoród", "Hungary", "47.5789", "19.2486");
INSERT INTO "circuits" VALUES ("10", "Spa-Francorchamps", "Spa", "Belgium", "50.4394", "5.97139");
INSERT INTO "circuits" VALUES ("11", "Autodromo Nazionale di Monza", "Monza", "Italy", "45.6156", "9.28111");
INSERT INTO "circuits" VALUES ("12", "Marina Bay Street Circuit", "Singapore", "Singapore", "1.29167", "103.864");
INSERT INTO "circuits" VALUES ("13", "Suzuka Circuit", "Suzuka", "Japan", "34.8431", "136.538");
INSERT INTO "circuits" VALUES ("14", "Autódromo José Carlos Pace", "São Paulo", "Brazil", "-23.7036", "-46.6997");
INSERT INTO "circuits" VALUES ("15", "Yas Marina Circuit", "Abu Dhabi", "UAE", "24.4672", "54.6031");
INSERT INTO "constructors" VALUES ("1", "McLaren", "British");
INSERT INTO "constructors" VALUES ("2", "Ferrari", "Italian");
INSERT INTO "constructors" VALUES ("3", "Williams", "British");
INSERT INTO "constructors" VALUES ("4", "Renault", "French");
INSERT INTO "constructors" VALUES ("5", "Mercedes", "German");
INSERT INTO "constructors" VALUES ("6", "Red Bull", "Austrian");
INSERT INTO "constructors" VALUES ("7", "Force India", "Indian");
INSERT INTO "constructors" VALUES ("8", "Sauber", "Swiss");
INSERT INTO "constructors" VALUES ("9", "Toro Rosso", "Italian");
INSERT INTO "constructors" VALUES ("10", "Haas F1 Team", "American");
INSERT INTO "races" VALUES ("1", "1", "Australian Grand Prix");
INSERT INTO "races" VALUES ("2", "2", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("3", "3", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("4", "4", "Spanish Grand Prix");
INSERT INTO "races" VALUES ("5", "5", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("6", "6", "Canadian Grand Prix");
INSERT INTO "races" VALUES ("7", "7", "British Grand Prix");
INSERT INTO "races" VALUES ("8", "8", "German Grand Prix");
INSERT INTO "races" VALUES ("9", "9", "Hungarian Grand Prix");
INSERT INTO "races" VALUES ("10", "10", "Belgian Grand Prix");
INSERT INTO "races" VALUES ("11", "11", "Italian Grand Prix");
INSERT INTO "races" VALUES ("12", "12", "Singapore Grand Prix");
INSERT INTO "races" VALUES ("13", "13", "Japanese Grand Prix");
INSERT INTO "races" VALUES ("14", "14", "Brazilian Grand Prix");
INSERT INTO "races" VALUES ("15", "15", "Abu Dhabi Grand Prix");
INSERT INTO "constructorResults" VALUES ("1", "1", "4");
INSERT INTO "constructorResults" VALUES ("2", "2", "4");
INSERT INTO "constructorResults" VALUES ("3", "3", "4");
INSERT INTO "constructorResults" VALUES ("4", "4", "4");
INSERT INTO "constructorResults" VALUES ("5", "5", "4");
INSERT INTO "constructorResults" VALUES ("6", "6", "1");
INSERT INTO "constructorResults" VALUES ("7", "7", "2");
INSERT INTO "constructorResults" VALUES ("8", "8", "3");
INSERT INTO "constructorResults" VALUES ("9", "9", "5");
INSERT INTO "constructorResults" VALUES ("10", "10", "6");
INSERT INTO "constructorResults" VALUES ("11", "11", "4");
INSERT INTO "constructorResults" VALUES ("12", "12", "4");
INSERT INTO "constructorResults" VALUES ("13", "13", "4");
INSERT INTO "constructorResults" VALUES ("14", "14", "4");
INSERT INTO "constructorResults" VALUES ("15", "15", "4");
INSERT INTO "constructorStandings" VALUES ("1", "10.0");
INSERT INTO "constructorStandings" VALUES ("2", "8.0");
INSERT INTO "constructorStandings" VALUES ("3", "6.0");
INSERT INTO "constructorStandings" VALUES ("4", "4.0");
INSERT INTO "constructorStandings" VALUES ("5", "2.0");