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 "races" (
"raceId" INT,
"name" TEXT,
PRIMARY KEY ("raceId")
);

CREATE TABLE "results" (
"resultId" INT,
"constructorId" INT,
PRIMARY KEY ("resultId"),
FOREIGN KEY ("constructorId") REFERENCES "constructors"("constructorId")
);



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", "British");
INSERT INTO "drivers" VALUES ("3", "German");
INSERT INTO "drivers" VALUES ("4", "German");
INSERT INTO "drivers" VALUES ("5", "British");
INSERT INTO "drivers" VALUES ("6", "Spanish");
INSERT INTO "drivers" VALUES ("7", "British");
INSERT INTO "drivers" VALUES ("8", "French");
INSERT INTO "drivers" VALUES ("9", "British");
INSERT INTO "drivers" VALUES ("10", "Finnish");
INSERT INTO "drivers" VALUES ("11", "British");
INSERT INTO "drivers" VALUES ("12", "German");
INSERT INTO "drivers" VALUES ("13", "British");
INSERT INTO "drivers" VALUES ("14", "British");
INSERT INTO "drivers" VALUES ("15", "British");
INSERT INTO "races" VALUES ("1", "Monaco Grand Prix");
INSERT INTO "races" VALUES ("2", "British Grand Prix");
INSERT INTO "races" VALUES ("3", "Italian Grand Prix");
INSERT INTO "races" VALUES ("4", "German Grand Prix");
INSERT INTO "races" VALUES ("5", "Spanish Grand Prix");
INSERT INTO "results" VALUES ("1", "1");
INSERT INTO "results" VALUES ("2", "1");
INSERT INTO "results" VALUES ("3", "2");
INSERT INTO "results" VALUES ("4", "3");
INSERT INTO "results" VALUES ("5", "1");
INSERT INTO "results" VALUES ("6", "4");
INSERT INTO "results" VALUES ("7", "2");
INSERT INTO "results" VALUES ("8", "5");
INSERT INTO "results" VALUES ("9", "1");
INSERT INTO "results" VALUES ("10", "3");