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 "drivers" (
"driverId" INT UNIQUE,
"surname" TEXT,
"nationality" TEXT,
PRIMARY KEY ("driverId")
);

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

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



INSERT INTO "drivers" VALUES ("1", "Hamilton", "British");
INSERT INTO "drivers" VALUES ("2", "Button", "British");
INSERT INTO "drivers" VALUES ("3", "Massa", "Brazilian");
INSERT INTO "drivers" VALUES ("4", "Raikkonen", "Finnish");
INSERT INTO "drivers" VALUES ("5", "Kubica", "Polish");
INSERT INTO "drivers" VALUES ("6", "Alonso", "Spanish");
INSERT INTO "drivers" VALUES ("7", "Heidfeld", "German");
INSERT INTO "drivers" VALUES ("8", "Sutil", "German");
INSERT INTO "drivers" VALUES ("9", "Bourdais", "French");
INSERT INTO "drivers" VALUES ("10", "Trulli", "Italian");
INSERT INTO "drivers" VALUES ("11", "Coulthard", "British");
INSERT INTO "drivers" VALUES ("12", "Barrichello", "Brazilian");
INSERT INTO "drivers" VALUES ("13", "Fisichella", "Italian");
INSERT INTO "drivers" VALUES ("14", "Webber", "Australian");
INSERT INTO "drivers" VALUES ("15", "Rosberg", "German");
INSERT INTO "drivers" VALUES ("16", "Nakajima", "Japanese");
INSERT INTO "drivers" VALUES ("17", "Sato", "Japanese");
INSERT INTO "drivers" VALUES ("18", "Kovalainen", "Finnish");
INSERT INTO "drivers" VALUES ("19", "de la Rosa", "Spanish");
INSERT INTO "drivers" VALUES ("20", "Liuzzi", "Italian");
INSERT INTO "drivers" VALUES ("21", "UN_Driver1", "British");
INSERT INTO "drivers" VALUES ("22", "UN_Driver2", "British");
INSERT INTO "drivers" VALUES ("23", "MultiNat", "British/Spanish");
INSERT INTO "races" VALUES ("101", "2008", "1", "Australian Grand Prix");
INSERT INTO "races" VALUES ("102", "2008", "2", "Malaysian Grand Prix");
INSERT INTO "races" VALUES ("103", "2008", "3", "Bahrain Grand Prix");
INSERT INTO "races" VALUES ("104", "2008", "4", "Spanish Grand Prix");
INSERT INTO "results" VALUES ("1001", "101", "1", "1");
INSERT INTO "results" VALUES ("1002", "101", "2", "3");
INSERT INTO "results" VALUES ("1003", "101", "3", "2");
INSERT INTO "results" VALUES ("1004", "101", "4", "4");
INSERT INTO "results" VALUES ("1005", "101", "5", "5");
INSERT INTO "results" VALUES ("1006", "101", "6", "6");
INSERT INTO "results" VALUES ("1007", "101", "7", "7");
INSERT INTO "results" VALUES ("1008", "101", "8", "8");
INSERT INTO "results" VALUES ("1009", "101", "9", "9");
INSERT INTO "results" VALUES ("1010", "101", "10", "10");
INSERT INTO "results" VALUES ("1011", "101", "11", "11");
INSERT INTO "results" VALUES ("1012", "101", "12", "12");
INSERT INTO "results" VALUES ("1013", "101", "21", "13");
INSERT INTO "results" VALUES ("1014", "101", "22", "14");
INSERT INTO "results" VALUES ("1015", "101", "23", "15");
INSERT INTO "results" VALUES ("1016", "102", "13", "1");
INSERT INTO "results" VALUES ("1017", "102", "14", "2");
INSERT INTO "results" VALUES ("1018", "102", "15", "3");
INSERT INTO "results" VALUES ("1019", "102", "16", "4");
INSERT INTO "results" VALUES ("1020", "102", "17", "5");
INSERT INTO "results" VALUES ("1021", "102", "18", "6");
INSERT INTO "results" VALUES ("1022", "102", "19", "7");
INSERT INTO "results" VALUES ("1023", "102", "20", "8");