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 "matches" (
"loser_id" INT,
"loser_name" TEXT,
"winner_id" INT,
"winner_name" TEXT,
"year" INT,
FOREIGN KEY ("loser_id") REFERENCES "players"("player_id"),
FOREIGN KEY ("winner_id") REFERENCES "players"("player_id")
);

CREATE TABLE "players" (
"player_id" INT UNIQUE,
"first_name" TEXT,
"last_name" TEXT,
"country_code" TEXT,
PRIMARY KEY ("player_id")
);





INSERT INTO "players" VALUES ("1", "Serena", "Williams", "USA");
INSERT INTO "players" VALUES ("2", "Maria", "Sharapova", "RUS");
INSERT INTO "players" VALUES ("3", "Victoria", "Azarenka", "BLR");
INSERT INTO "players" VALUES ("4", "Simona", "Halep", "ROU");
INSERT INTO "players" VALUES ("5", "Angelique", "Kerber", "GER");
INSERT INTO "players" VALUES ("6", "Caroline", "Wozniacki", "DEN");
INSERT INTO "players" VALUES ("7", "Petra", "Kvitova", "CZE");
INSERT INTO "players" VALUES ("8", "Agnieszka", "Radwanska", "POL");
INSERT INTO "players" VALUES ("9", "Garbiñe", "Muguruza", "ESP");
INSERT INTO "players" VALUES ("10", "Venus", "Williams", "USA");
INSERT INTO "players" VALUES ("11", "Naomi", "Osaka", "JPN");
INSERT INTO "players" VALUES ("12", "Ashleigh", "Barty", "AUS");
INSERT INTO "players" VALUES ("13", "Elina", "Svitolina", "UKR");
INSERT INTO "players" VALUES ("14", "Karolina", "Pliskova", "CZE");
INSERT INTO "players" VALUES ("15", "Sloane", "Stephens", "USA");
INSERT INTO "matches" VALUES ("2", "Maria Sharapova", "1", "Serena Williams", "2013");
INSERT INTO "matches" VALUES ("3", "Victoria Azarenka", "1", "Serena Williams", "2013");
INSERT INTO "matches" VALUES ("4", "Simona Halep", "2", "Maria Sharapova", "2013");
INSERT INTO "matches" VALUES ("5", "Angelique Kerber", "3", "Victoria Azarenka", "2013");
INSERT INTO "matches" VALUES ("1", "Serena Williams", "4", "Simona Halep", "2016");
INSERT INTO "matches" VALUES ("2", "Maria Sharapova", "5", "Angelique Kerber", "2016");
INSERT INTO "matches" VALUES ("3", "Victoria Azarenka", "1", "Serena Williams", "2016");
INSERT INTO "matches" VALUES ("6", "Caroline Wozniacki", "7", "Petra Kvitova", "2013");
INSERT INTO "matches" VALUES ("8", "Agnieszka Radwanska", "9", "Garbiñe Muguruza", "2013");
INSERT INTO "matches" VALUES ("10", "Venus Williams", "1", "Serena Williams", "2013");
INSERT INTO "matches" VALUES ("11", "Naomi Osaka", "12", "Ashleigh Barty", "2016");
INSERT INTO "matches" VALUES ("13", "Elina Svitolina", "14", "Karolina Pliskova", "2016");
INSERT INTO "matches" VALUES ("15", "Sloane Stephens", "1", "Serena Williams", "2016");
INSERT INTO "matches" VALUES ("1", "Serena Williams", "2", "Maria Sharapova", "2016");
INSERT INTO "matches" VALUES ("4", "Simona Halep", "3", "Victoria Azarenka", "2013");
INSERT INTO "matches" VALUES ("5", "Angelique Kerber", "4", "Simona Halep", "2016");
INSERT INTO "matches" VALUES ("7", "Petra Kvitova", "6", "Caroline Wozniacki", "2016");
INSERT INTO "matches" VALUES ("9", "Garbiñe Muguruza", "8", "Agnieszka Radwanska", "2016");
INSERT INTO "matches" VALUES ("12", "Ashleigh Barty", "10", "Venus Williams", "2013");
INSERT INTO "matches" VALUES ("14", "Karolina Pliskova", "11", "Naomi Osaka", "2013");
INSERT INTO "matches" VALUES ("1", "Serena Williams", "13", "Elina Svitolina", "2013");
INSERT INTO "matches" VALUES ("2", "Maria Sharapova", "15", "Sloane Stephens", "2013");
INSERT INTO "matches" VALUES ("10", "Venus Williams", "1", "Serena Williams", "2016");
INSERT INTO "matches" VALUES ("1", "Serena Williams", "10", "Venus Williams", "2013");
INSERT INTO "matches" VALUES ("1", "Serena Williams", "10", "Venus Williams", "2016");
INSERT INTO "matches" VALUES ("10", "Venus Williams", "1", "Serena Williams", "2013");
INSERT INTO "matches" VALUES ("10", "Venus Williams", "1", "Serena Williams", "2016");