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

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





INSERT INTO "players" VALUES ("1", "Serena", "1981-09-26", "USA");
INSERT INTO "players" VALUES ("2", "Venus", "1980-06-17", "USA");
INSERT INTO "players" VALUES ("3", "Maria", "1987-06-19", "RUS");
INSERT INTO "players" VALUES ("4", "Simona", "1990-04-25", "ROU");
INSERT INTO "players" VALUES ("5", "Naomi", "1997-10-16", "JPN");
INSERT INTO "players" VALUES ("6", "Ashleigh", "1996-07-24", "AUS");
INSERT INTO "players" VALUES ("7", "Petra", "1990-06-08", "CZE");
INSERT INTO "players" VALUES ("8", "Bianca", "1996-06-24", "ROU");
INSERT INTO "matches" VALUES ("2", "1", "8500");
INSERT INTO "matches" VALUES ("3", "1", "8700");
INSERT INTO "matches" VALUES ("4", "2", "7200");
INSERT INTO "matches" VALUES ("5", "3", "6800");
INSERT INTO "matches" VALUES ("6", "4", "7100");
INSERT INTO "matches" VALUES ("7", "5", "6900");
INSERT INTO "matches" VALUES ("8", "6", "6700");
INSERT INTO "matches" VALUES ("1", "7", "6600");
INSERT INTO "matches" VALUES ("2", "8", "6500");
INSERT INTO "matches" VALUES ("3", "1", "8800");
INSERT INTO "matches" VALUES ("4", "1", "8800");
INSERT INTO "matches" VALUES ("5", "1", "8800");
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");