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", "Petra", "Kvitova", "CZE");
INSERT INTO "players" VALUES ("7", "Caroline", "Wozniacki", "DEN");
INSERT INTO "players" VALUES ("8", "Garbiñe", "Muguruza", "ESP");
INSERT INTO "players" VALUES ("9", "Naomi", "Osaka", "JPN");
INSERT INTO "players" VALUES ("10", "Ashleigh", "Barty", "AUS");
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", "1", "Serena Williams", "2013");
INSERT INTO "matches" VALUES ("5", "Angelique Kerber", "2", "Maria Sharapova", "2013");
INSERT INTO "matches" VALUES ("6", "Petra Kvitova", "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", "5", "Angelique Kerber", "2016");
INSERT INTO "matches" VALUES ("4", "Simona Halep", "6", "Petra Kvitova", "2016");
INSERT INTO "matches" VALUES ("7", "Caroline Wozniacki", "1", "Serena Williams", "2016");
INSERT INTO "matches" VALUES ("8", "Garbiñe Muguruza", "1", "Serena Williams", "2016");
INSERT INTO "matches" VALUES ("9", "Naomi Osaka", "4", "Simona Halep", "2013");
INSERT INTO "matches" VALUES ("10", "Ashleigh Barty", "4", "Simona Halep", "2016");
INSERT INTO "matches" VALUES ("1", "Serena Williams", "2", "Maria Sharapova", "2013");
INSERT INTO "matches" VALUES ("5", "Angelique Kerber", "1", "Serena Williams", "2013");
INSERT INTO "matches" VALUES ("6", "Petra Kvitova", "1", "Serena Williams", "2016");
INSERT INTO "matches" VALUES ("7", "Caroline Wozniacki", "2", "Maria Sharapova", "2013");
INSERT INTO "matches" VALUES ("8", "Garbiñe Muguruza", "3", "Victoria Azarenka", "2013");
INSERT INTO "matches" VALUES ("9", "Naomi Osaka", "5", "Angelique Kerber", "2016");
INSERT INTO "matches" VALUES ("10", "Ashleigh Barty", "6", "Petra Kvitova", "2016");
INSERT INTO "matches" VALUES ("1", "Serena Williams", "7", "Caroline Wozniacki", "2013");
INSERT INTO "matches" VALUES ("2", "Maria Sharapova", "8", "Garbiñe Muguruza", "2016");
INSERT INTO "matches" VALUES ("3", "Victoria Azarenka", "9", "Naomi Osaka", "2013");
INSERT INTO "matches" VALUES ("4", "Simona Halep", "10", "Ashleigh Barty", "2016");
INSERT INTO "matches" VALUES ("5", "Angelique Kerber", "7", "Caroline Wozniacki", "2016");
INSERT INTO "matches" VALUES ("6", "Petra Kvitova", "8", "Garbiñe Muguruza", "2013");
INSERT INTO "matches" VALUES ("7", "Caroline Wozniacki", "9", "Naomi Osaka", "2016");
INSERT INTO "matches" VALUES ("8", "Garbiñe Muguruza", "10", "Ashleigh Barty", "2013");