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,
"tourney_date" DATE,
"winner_id" 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", "Simona", "Halep", "ROU");
INSERT INTO "players" VALUES ("3", "Naomi", "Osaka", "JPN");
INSERT INTO "players" VALUES ("4", "Ashleigh", "Barty", "AUS");
INSERT INTO "players" VALUES ("5", "Petra", "Kvitova", "CZE");
INSERT INTO "players" VALUES ("6", "Sofia", "Kenin", "USA");
INSERT INTO "players" VALUES ("7", "Elina", "Svitolina", "UKR");
INSERT INTO "players" VALUES ("8", "Karolina", "Pliskova", "CZE");
INSERT INTO "players" VALUES ("9", "Bianca", "Andreescu", "CAN");
INSERT INTO "players" VALUES ("10", "Garbiñe", "Muguruza", "ESP");
INSERT INTO "matches" VALUES ("1", "Serena Williams", "2023-01-15", "2");
INSERT INTO "matches" VALUES ("3", "Naomi Osaka", "2023-01-16", "1");
INSERT INTO "matches" VALUES ("2", "Simona Halep", "2023-01-17", "4");
INSERT INTO "matches" VALUES ("5", "Petra Kvitova", "2023-01-18", "3");
INSERT INTO "matches" VALUES ("6", "Sofia Kenin", "2023-01-19", "5");
INSERT INTO "matches" VALUES ("7", "Elina Svitolina", "2023-01-20", "6");
INSERT INTO "matches" VALUES ("8", "Karolina Pliskova", "2023-01-21", "7");
INSERT INTO "matches" VALUES ("9", "Bianca Andreescu", "2023-01-22", "8");
INSERT INTO "matches" VALUES ("10", "Garbiñe Muguruza", "2023-01-23", "9");
INSERT INTO "matches" VALUES ("1", "Serena Williams", "2023-01-24", "10");
INSERT INTO "matches" VALUES ("2", "Simona Halep", "2023-01-25", "1");
INSERT INTO "matches" VALUES ("3", "Naomi Osaka", "2023-01-26", "4");
INSERT INTO "matches" VALUES ("4", "Ashleigh Barty", "2023-01-27", "5");
INSERT INTO "matches" VALUES ("5", "Petra Kvitova", "2023-01-28", "6");
INSERT INTO "matches" VALUES ("6", "Sofia Kenin", "2023-01-29", "7");
INSERT INTO "matches" VALUES ("7", "Elina Svitolina", "2023-01-30", "8");
INSERT INTO "matches" VALUES ("8", "Karolina Pliskova", "2023-01-31", "9");
INSERT INTO "matches" VALUES ("9", "Bianca Andreescu", "2023-02-01", "10");
INSERT INTO "matches" VALUES ("10", "Garbiñe Muguruza", "2023-02-02", "1");