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,
"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,
"birth_date" DATE,
PRIMARY KEY ("player_id")
);

CREATE TABLE "rankings" (
"ranking" INT
);





INSERT INTO "players" VALUES ("1", "Serena", "Williams", "1981-09-26");
INSERT INTO "players" VALUES ("2", "Maria", "Sharapova", "1987-04-19");
INSERT INTO "players" VALUES ("3", "Simona", "Halep", "1991-09-27");
INSERT INTO "players" VALUES ("4", "Angelique", "Kerber", "1988-01-18");
INSERT INTO "players" VALUES ("5", "Victoria", "Azarenka", "1989-07-31");
INSERT INTO "players" VALUES ("6", "Petra", "Kvitova", "1990-03-08");
INSERT INTO "players" VALUES ("7", "Caroline", "Wozniacki", "1990-07-11");
INSERT INTO "players" VALUES ("8", "Garbiñe", "Muguruza", "1993-10-08");
INSERT INTO "players" VALUES ("9", "Elina", "Svitolina", "1994-09-12");
INSERT INTO "players" VALUES ("10", "Sloane", "Stephens", "1993-03-20");
INSERT INTO "matches" VALUES ("2", "1", "Serena Williams", "2013");
INSERT INTO "matches" VALUES ("3", "1", "Serena Williams", "2013");
INSERT INTO "matches" VALUES ("4", "1", "Serena Williams", "2016");
INSERT INTO "matches" VALUES ("5", "1", "Serena Williams", "2016");
INSERT INTO "matches" VALUES ("1", "2", "Maria Sharapova", "2013");
INSERT INTO "matches" VALUES ("6", "2", "Maria Sharapova", "2013");
INSERT INTO "matches" VALUES ("7", "2", "Maria Sharapova", "2014");
INSERT INTO "matches" VALUES ("8", "3", "Simona Halep", "2013");
INSERT INTO "matches" VALUES ("9", "3", "Simona Halep", "2016");
INSERT INTO "matches" VALUES ("10", "3", "Simona Halep", "2016");
INSERT INTO "matches" VALUES ("1", "4", "Angelique Kerber", "2016");
INSERT INTO "matches" VALUES ("2", "4", "Angelique Kerber", "2016");
INSERT INTO "matches" VALUES ("3", "5", "Victoria Azarenka", "2013");
INSERT INTO "matches" VALUES ("4", "5", "Victoria Azarenka", "2014");
INSERT INTO "matches" VALUES ("5", "6", "Petra Kvitova", "2013");
INSERT INTO "matches" VALUES ("6", "6", "Petra Kvitova", "2016");
INSERT INTO "matches" VALUES ("7", "7", "Caroline Wozniacki", "2013");
INSERT INTO "matches" VALUES ("8", "7", "Caroline Wozniacki", "2015");
INSERT INTO "matches" VALUES ("9", "8", "Garbiñe Muguruza", "2016");
INSERT INTO "matches" VALUES ("10", "8", "Garbiñe Muguruza", "2016");
INSERT INTO "matches" VALUES ("1", "9", "Elina Svitolina", "2016");
INSERT INTO "matches" VALUES ("2", "10", "Sloane Stephens", "2013");
INSERT INTO "matches" VALUES ("3", "10", "Sloane Stephens", "2016");
INSERT INTO "rankings" VALUES ("1");
INSERT INTO "rankings" VALUES ("2");
INSERT INTO "rankings" VALUES ("3");
INSERT INTO "rankings" VALUES ("4");
INSERT INTO "rankings" VALUES ("5");
INSERT INTO "rankings" VALUES ("6");
INSERT INTO "rankings" VALUES ("7");
INSERT INTO "rankings" VALUES ("8");
INSERT INTO "rankings" VALUES ("9");
INSERT INTO "rankings" VALUES ("10");