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 "constructors" (
"constructorId" INT,
"nationality" TEXT,
PRIMARY KEY ("constructorId")
);

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

CREATE TABLE "qualifying" (
"qualifyId" INT,
"raceId" INT,
"driverId" INT,
"q1" TEXT,
"q2" TEXT,
PRIMARY KEY ("qualifyId"),
FOREIGN KEY ("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
);

CREATE TABLE "races" (
"raceId" INT,
"name" TEXT,
PRIMARY KEY ("raceId")
);



INSERT INTO "constructors" VALUES ("1", "British");
INSERT INTO "constructors" VALUES ("2", "German");
INSERT INTO "constructors" VALUES ("3", "Italian");
INSERT INTO "constructors" VALUES ("4", "French");
INSERT INTO "constructors" VALUES ("5", "American");
INSERT INTO "drivers" VALUES ("1", "British");
INSERT INTO "drivers" VALUES ("2", "German");
INSERT INTO "drivers" VALUES ("3", "Spanish");
INSERT INTO "drivers" VALUES ("4", "Finnish");
INSERT INTO "drivers" VALUES ("5", "Dutch");
INSERT INTO "drivers" VALUES ("6", "Australian");
INSERT INTO "drivers" VALUES ("7", "French");
INSERT INTO "drivers" VALUES ("8", "Mexican");
INSERT INTO "drivers" VALUES ("9", "Canadian");
INSERT INTO "drivers" VALUES ("10", "Monegasque");
INSERT INTO "qualifying" VALUES ("1", "355", "1", "0:01:35.123", "0:01:40.000");
INSERT INTO "qualifying" VALUES ("2", "355", "2", "0:01:36.456", "0:01:41.234");
INSERT INTO "qualifying" VALUES ("3", "355", "3", "0:01:37.789", "0:01:42.567");
INSERT INTO "qualifying" VALUES ("4", "356", "1", "0:01:30.100", "0:01:35.000");
INSERT INTO "qualifying" VALUES ("5", "356", "4", "0:01:31.200", "0:01:36.100");
INSERT INTO "qualifying" VALUES ("6", "357", "5", "0:01:32.300", "0:01:37.200");
INSERT INTO "qualifying" VALUES ("7", "355", "6", "0:01:38.000", "0:01:40.000");
INSERT INTO "qualifying" VALUES ("8", "355", "7", "0:01:39.000", "0:01:43.000");
INSERT INTO "qualifying" VALUES ("9", "355", "8", "0:01:40.000", "0:01:44.000");
INSERT INTO "qualifying" VALUES ("10", "355", "9", "0:01:41.000", "0:01:45.000");
INSERT INTO "qualifying" VALUES ("11", "355", "10", "0:01:42.000", "0:01:46.000");
INSERT INTO "races" VALUES ("355", "Grand Prix of Monaco");
INSERT INTO "races" VALUES ("356", "Grand Prix of Italy");
INSERT INTO "races" VALUES ("357", "Grand Prix of Britain");
INSERT INTO "races" VALUES ("358", "Grand Prix of Japan");
INSERT INTO "races" VALUES ("359", "Grand Prix of Brazil");