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,
"country" TEXT,
"lat" FLOAT,
"lng" FLOAT,
PRIMARY KEY ("circuitId")
);

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



INSERT INTO "circuits" VALUES ("1", "Sepang International Circuit", "Malaysia", "2.76083", "101.738");
INSERT INTO "circuits" VALUES ("2", "Albert Park Grand Prix Circuit", "Australia", "-37.8497", "144.968");
INSERT INTO "circuits" VALUES ("3", "Shanghai International Circuit", "China", "31.3389", "121.22");
INSERT INTO "circuits" VALUES ("4", "Bahrain International Circuit", "Bahrain", "26.0325", "50.5106");
INSERT INTO "circuits" VALUES ("5", "Circuit de Barcelona-Catalunya", "Spain", "41.57", "2.26111");
INSERT INTO "circuits" VALUES ("6", "Circuit de Monaco", "Monaco", "43.7347", "7.42056");
INSERT INTO "circuits" VALUES ("7", "Circuit Gilles Villeneuve", "Canada", "45.5228", "-73.5258");
INSERT INTO "circuits" VALUES ("8", "Silverstone Circuit", "UK", "52.0786", "-1.01694");
INSERT INTO "circuits" VALUES ("9", "Hockenheimring", "Germany", "49.3278", "8.56583");
INSERT INTO "circuits" VALUES ("10", "Hungaroring", "Hungary", "47.5789", "19.2506");
INSERT INTO "races" VALUES ("1", "1", "Malaysian Grand Prix", "2017-09-29");
INSERT INTO "races" VALUES ("2", "2", "Australian Grand Prix", "2017-03-26");
INSERT INTO "races" VALUES ("3", "3", "Chinese Grand Prix", "2017-04-09");
INSERT INTO "races" VALUES ("4", "4", "Bahrain Grand Prix", "2017-04-16");
INSERT INTO "races" VALUES ("5", "5", "Spanish Grand Prix", "2017-05-14");
INSERT INTO "races" VALUES ("6", "6", "Monaco Grand Prix", "2017-05-28");
INSERT INTO "races" VALUES ("7", "7", "Canadian Grand Prix", "2017-06-11");
INSERT INTO "races" VALUES ("8", "8", "British Grand Prix", "2017-07-16");
INSERT INTO "races" VALUES ("9", "9", "German Grand Prix", "2016-07-31");
INSERT INTO "races" VALUES ("10", "10", "Hungarian Grand Prix", "2017-07-30");
INSERT INTO "races" VALUES ("11", "1", "Malaysian Grand Prix", "2016-10-02");
INSERT INTO "races" VALUES ("12", "1", "Malaysian Grand Prix", "2015-03-29");
INSERT INTO "races" VALUES ("13", "2", "Australian Grand Prix", "2016-03-20");
INSERT INTO "races" VALUES ("14", "3", "Chinese Grand Prix", "2016-04-17");