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 "circuits" (
"circuitId" INT UNIQUE,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" FLOAT,
PRIMARY KEY ("circuitId")
);

CREATE TABLE "races" (
"raceId" INT,
"year" INT,
"round" INT,
"circuitId" INT,
"name" TEXT,
"date" DATE,
PRIMARY KEY ("raceId"),
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
);



INSERT INTO "circuits" VALUES ("1", "Silverstone Circuit", "Silverstone", "United Kingdom", "52.0786");
INSERT INTO "circuits" VALUES ("2", "Circuit de Spa-Francorchamps", "Stavelot", "Belgium", "50.4372");
INSERT INTO "circuits" VALUES ("3", "Monza Circuit", "Monza", "Italy", "45.6156");
INSERT INTO "circuits" VALUES ("4", "Circuit de Monaco", "Monte Carlo", "Monaco", "43.7347");
INSERT INTO "circuits" VALUES ("5", "Hockenheimring", "Hockenheim", "Germany", "49.3278");
INSERT INTO "circuits" VALUES ("6", "Circuit de Barcelona-Catalunya", "Montmeló", "Spain", "41.5700");
INSERT INTO "races" VALUES ("101", "1950", "1", "1", "British Grand Prix", "1950-05-13");
INSERT INTO "races" VALUES ("102", "1950", "2", "2", "Belgian Grand Prix", "1950-06-18");
INSERT INTO "races" VALUES ("103", "1950", "3", "3", "Italian Grand Prix", "1950-09-03");
INSERT INTO "races" VALUES ("104", "1950", "4", "4", "Monaco Grand Prix", "1950-05-21");
INSERT INTO "races" VALUES ("105", "1950", "5", "5", "German Grand Prix", "1950-08-06");
INSERT INTO "races" VALUES ("106", "1950", "6", "6", "European Grand Prix", "1950-09-17");
INSERT INTO "races" VALUES ("201", "1947", "1", "2", "Belgian Grand Prix", "1947-07-06");
INSERT INTO "races" VALUES ("202", "1947", "2", "3", "Italian Grand Prix", "1947-09-07");
INSERT INTO "races" VALUES ("203", "1947", "3", "1", "European Grand Prix", "1947-08-24");
INSERT INTO "races" VALUES ("204", "1947", "4", "5", "German Grand Prix", "1947-08-10");