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_hand" TEXT,
"tourney_level" TEXT,
"tourney_name" TEXT,
"winner_hand" TEXT,
"winner_id" INT,
FOREIGN KEY ("winner_id") REFERENCES "players"("player_id")
);

CREATE TABLE "players" (
"player_id" INT UNIQUE,
"hand" TEXT,
"birth_date" DATE,
PRIMARY KEY ("player_id")
);





INSERT INTO "players" VALUES ("1", "L", "1985-04-12");
INSERT INTO "players" VALUES ("2", "R", "1990-07-23");
INSERT INTO "players" VALUES ("3", "L", "1988-11-05");
INSERT INTO "players" VALUES ("4", "R", "1992-02-17");
INSERT INTO "players" VALUES ("5", "L", "1983-09-30");
INSERT INTO "players" VALUES ("6", "R", "1987-06-14");
INSERT INTO "players" VALUES ("7", "L", "1991-12-01");
INSERT INTO "players" VALUES ("8", "R", "1989-03-22");
INSERT INTO "matches" VALUES ("R", "WTA Championships", "WTA Championships 2019", "L", "1");
INSERT INTO "matches" VALUES ("L", "WTA Championships", "WTA Championships 2019", "R", "2");
INSERT INTO "matches" VALUES ("R", "WTA Championships", "WTA Championships 2020", "L", "3");
INSERT INTO "matches" VALUES ("L", "Grand Slam", "US Open 2019", "R", "4");
INSERT INTO "matches" VALUES ("R", "WTA Championships", "WTA Championships 2020", "L", "5");
INSERT INTO "matches" VALUES ("L", "WTA 1000", "Miami Open 2020", "R", "6");
INSERT INTO "matches" VALUES ("R", "WTA Championships", "WTA Championships 2021", "L", "7");
INSERT INTO "matches" VALUES ("L", "WTA 500", "Stuttgart Open 2021", "R", "8");
INSERT INTO "matches" VALUES ("R", "WTA Championships", "WTA Championships 2021", "R", "2");
INSERT INTO "matches" VALUES ("L", "WTA Championships", "WTA Championships 2019", "L", "1");
INSERT INTO "matches" VALUES ("R", "WTA Championships", "WTA Championships 2020", "L", "3");
INSERT INTO "matches" VALUES ("L", "WTA Championships", "WTA Championships 2021", "L", "5");