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,
"surface" TEXT,
"winner_age" FLOAT,
"winner_id" INT,
"winner_name" TEXT,
"winner_rank" 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" (
"player_id" INT,
FOREIGN KEY ("player_id") REFERENCES "players"("player_id")
);





INSERT INTO "players" VALUES ("1", "Serena", "Williams", "1990-09-26");
INSERT INTO "players" VALUES ("2", "Venus", "Williams", "1980-06-17");
INSERT INTO "players" VALUES ("3", "Naomi", "Osaka", "1997-10-16");
INSERT INTO "players" VALUES ("4", "Iga", "Swiatek", "2001-05-31");
INSERT INTO "players" VALUES ("5", "Coco", "Gauff", "2004-03-13");
INSERT INTO "players" VALUES ("6", "Simona", "Halep", "1991-09-27");
INSERT INTO "players" VALUES ("7", "Ashleigh", "Barty", "1996-04-24");
INSERT INTO "players" VALUES ("8", "Bianca", "Andreescu", "2000-06-16");
INSERT INTO "players" VALUES ("9", "Petra", "Kvitova", "1990-03-08");
INSERT INTO "players" VALUES ("10", "Sofia", "Kenin", "1998-11-14");
INSERT INTO "matches" VALUES ("2", "Hard", "22.5", "5", "Coco Gauff", "50");
INSERT INTO "matches" VALUES ("3", "Clay", "19.8", "4", "Iga Swiatek", "15");
INSERT INTO "matches" VALUES ("1", "Grass", "23.0", "7", "Ashleigh Barty", "10");
INSERT INTO "matches" VALUES ("6", "Hard", "24.0", "1", "Serena Williams", "5");
INSERT INTO "matches" VALUES ("7", "Clay", "25.0", "6", "Simona Halep", "8");
INSERT INTO "matches" VALUES ("8", "Hard", "21.0", "10", "Sofia Kenin", "20");
INSERT INTO "matches" VALUES ("9", "Grass", "30.0", "2", "Venus Williams", "12");
INSERT INTO "matches" VALUES ("10", "Hard", "23.5", "3", "Naomi Osaka", "7");
INSERT INTO "matches" VALUES ("5", "Clay", "18.0", "8", "Bianca Andreescu", "18");
INSERT INTO "matches" VALUES ("4", "Hard", "20.0", "9", "Petra Kvitova", "25");
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");