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,
"constructorId" INT,
PRIMARY KEY ("constructorResultsId"),
FOREIGN KEY ("constructorId") REFERENCES "constructors"("constructorId")
);

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

CREATE TABLE "drivers" (
"driverId" INT UNIQUE,
"forename" TEXT,
"surname" TEXT,
PRIMARY KEY ("driverId")
);

CREATE TABLE "qualifying" (
"qualifyId" INT,
"position" INT,
PRIMARY KEY ("qualifyId")
);

CREATE TABLE "races" (
"raceId" INT UNIQUE,
"year" INT,
PRIMARY KEY ("raceId")
);

CREATE TABLE "results" (
"resultId" INT,
"raceId" INT,
"driverId" INT,
"points" FLOAT,
PRIMARY KEY ("resultId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);



INSERT INTO "constructorResults" VALUES ("1", "1");
INSERT INTO "constructorResults" VALUES ("2", "2");
INSERT INTO "constructorResults" VALUES ("3", "3");
INSERT INTO "constructorResults" VALUES ("4", "4");
INSERT INTO "constructorResults" VALUES ("5", "5");
INSERT INTO "constructorResults" VALUES ("6", "6");
INSERT INTO "constructors" VALUES ("1", "Ferrari");
INSERT INTO "constructors" VALUES ("2", "McLaren");
INSERT INTO "constructors" VALUES ("3", "Jordan");
INSERT INTO "constructors" VALUES ("4", "Williams");
INSERT INTO "constructors" VALUES ("5", "Benetton");
INSERT INTO "constructors" VALUES ("6", "Sauber");
INSERT INTO "drivers" VALUES ("1", "Michael", "Schumacher");
INSERT INTO "drivers" VALUES ("2", "Eddie", "Irvine");
INSERT INTO "drivers" VALUES ("3", "Mika", "Hakkinen");
INSERT INTO "drivers" VALUES ("4", "David", "Coulthard");
INSERT INTO "drivers" VALUES ("5", "Rubens", "Barrichello");
INSERT INTO "drivers" VALUES ("6", "Heinz-Harald", "Frentzen");
INSERT INTO "drivers" VALUES ("7", "Jarno", "Trulli");
INSERT INTO "drivers" VALUES ("8", "Ralf", "Schumacher");
INSERT INTO "drivers" VALUES ("9", "Jacques", "Villeneuve");
INSERT INTO "drivers" VALUES ("10", "Giancarlo", "Fisichella");
INSERT INTO "qualifying" VALUES ("1", "1");
INSERT INTO "qualifying" VALUES ("2", "2");
INSERT INTO "qualifying" VALUES ("3", "3");
INSERT INTO "qualifying" VALUES ("4", "4");
INSERT INTO "qualifying" VALUES ("5", "5");
INSERT INTO "qualifying" VALUES ("6", "6");
INSERT INTO "races" VALUES ("1", "2000");
INSERT INTO "races" VALUES ("2", "2000");
INSERT INTO "races" VALUES ("3", "2000");
INSERT INTO "races" VALUES ("4", "2000");
INSERT INTO "races" VALUES ("5", "2001");
INSERT INTO "races" VALUES ("6", "2001");
INSERT INTO "races" VALUES ("7", "1999");
INSERT INTO "races" VALUES ("8", "1999");
INSERT INTO "results" VALUES ("1", "1", "2", "6.0");
INSERT INTO "results" VALUES ("2", "1", "1", "10.0");
INSERT INTO "results" VALUES ("3", "2", "2", "4.0");
INSERT INTO "results" VALUES ("4", "2", "3", "6.0");
INSERT INTO "results" VALUES ("5", "3", "2", "0.0");
INSERT INTO "results" VALUES ("6", "3", "4", "10.0");
INSERT INTO "results" VALUES ("7", "4", "2", "2.0");
INSERT INTO "results" VALUES ("8", "4", "5", "6.0");
INSERT INTO "results" VALUES ("9", "5", "2", "1.0");
INSERT INTO "results" VALUES ("10", "5", "1", "10.0");
INSERT INTO "results" VALUES ("11", "6", "2", "3.0");
INSERT INTO "results" VALUES ("12", "6", "3", "8.0");
INSERT INTO "results" VALUES ("13", "7", "2", "10.0");
INSERT INTO "results" VALUES ("14", "8", "2", "6.0");
INSERT INTO "results" VALUES ("15", "1", "6", "3.0");
INSERT INTO "results" VALUES ("16", "2", "7", "1.0");
INSERT INTO "results" VALUES ("17", "3", "8", "2.0");
INSERT INTO "results" VALUES ("18", "4", "9", "0.0");
INSERT INTO "results" VALUES ("19", "5", "10", "4.0");