-- Database: chessleague

-- DROP DATABASE chessleague;

-- CREATE DATABASE chessleague
--     WITH 
--     OWNER = postgres
--     ENCODING = 'UTF8'
--     LC_COLLATE = 'German_Germany.1252'
--     LC_CTYPE = 'German_Germany.1252'
--     TABLESPACE = pg_default
--     CONNECTION LIMIT = -1;

DROP TABLE IF EXISTS "player" CASCADE;
DROP TABLE IF EXISTS "player_info" CASCADE;
DROP TABLE IF EXISTS "game" CASCADE;
DROP TABLE IF EXISTS "game_info" CASCADE;
DROP TABLE IF EXISTS "match" CASCADE;
DROP TABLE IF EXISTS "matchday" CASCADE;
DROP TABLE IF EXISTS "season" CASCADE;

CREATE TABLE "player" (
  "id" SERIAL PRIMARY KEY,
  "name" varchar NOT NULL,
  "nickname" varchar NOT NULL,
  "info" int UNIQUE
);

CREATE TABLE "player_info" (
  "id" SERIAL PRIMARY KEY,
  "url" varchar
);

CREATE TABLE "game" (
  "id" SERIAL PRIMARY KEY,
  "match" int NOT NULL,
  "player1_is_white" boolean NOT NULL,
  "result" int NOT NULL,
  "info" int UNIQUE
);

CREATE TABLE "game_info" (
  "id" SERIAL PRIMARY KEY,
  "format" int,
  "url" varchar
);


CREATE TABLE "match" (
  "id" SERIAL PRIMARY KEY,
  "player1" int NOT NULL,
  "player2" int NOT NULL,
  "matchday" int NOT NULL
);

CREATE TABLE "matchday" (
  "id" SERIAL PRIMARY KEY,
  "number" int NOT NULL,
  "season" int NOT NULL
);

CREATE TABLE "season" (
  "id" SERIAL PRIMARY KEY,
  "year_start" int NOT NULL,
  "year_end" int NOT NULL
);

ALTER TABLE "player" ADD FOREIGN KEY ("info") REFERENCES "player_info" ("id");

ALTER TABLE "game" ADD FOREIGN KEY ("match") REFERENCES "match" ("id");

ALTER TABLE "game" ADD FOREIGN KEY ("info") REFERENCES "game_info" ("id");

ALTER TABLE "match" ADD FOREIGN KEY ("player1") REFERENCES "player" ("id");

ALTER TABLE "match" ADD FOREIGN KEY ("player2") REFERENCES "player" ("id");

ALTER TABLE "match" ADD FOREIGN KEY ("matchday") REFERENCES "matchday" ("id");

ALTER TABLE "matchday" ADD FOREIGN KEY ("season") REFERENCES "season" ("id");

INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/aprilem262');
INSERT INTO "player" (name, nickname, info) VALUES ('Sophia', 'aprilem262', (SELECT id from player_info WHERE url='https://www.chess.com/member/aprilem262') );

INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/friedox');
INSERT INTO "player" (name, nickname, info) VALUES ('Friedi', 'friedox', (SELECT id from player_info WHERE url='https://www.chess.com/member/friedox') );

INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/internity');
INSERT INTO "player" (name, nickname, info) VALUES ('Albert', 'internity', (SELECT id from player_info WHERE url='https://www.chess.com/member/internity') );

INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/kevske');
INSERT INTO "player" (name, nickname, info) VALUES ('Kevin', 'kevske', (SELECT id from player_info WHERE url='https://www.chess.com/member/kevske') );

INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/kochi291');
INSERT INTO "player" (name, nickname, info) VALUES ('Marcel', 'Kochi291', (SELECT id from player_info WHERE url='https://www.chess.com/member/kochi291') );

INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/ladyanne26');
INSERT INTO "player" (name, nickname, info) VALUES ('Anne', 'LadyAnne26', (SELECT id from player_info WHERE url='https://www.chess.com/member/ladyanne26') );

INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/lakes0');
INSERT INTO "player" (name, nickname, info) VALUES ('Florian', 'Lakes0', (SELECT id from player_info WHERE url='https://www.chess.com/member/lakes0') );

INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/maddingladi');
INSERT INTO "player" (name, nickname, info) VALUES ('Maddin', 'maddingladi', (SELECT id from player_info WHERE url='https://www.chess.com/member/maddingladi') );

INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/magnus_brother');
INSERT INTO "player" (name, nickname, info) VALUES ('Tariq', 'Magnus_brother', (SELECT id from player_info WHERE url='https://www.chess.com/member/magnus_brother') );

INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/mama-lolo');
INSERT INTO "player" (name, nickname, info) VALUES ('Malte', 'Mama-Lolo', (SELECT id from player_info WHERE url='https://www.chess.com/member/mama-lolo') );

INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/marcriedlsperger');
INSERT INTO "player" (name, nickname, info) VALUES ('Marc', 'marcriedlsperger', (SELECT id from player_info WHERE url='https://www.chess.com/member/marcriedlsperger') );

INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/mistmade03');
INSERT INTO "player" (name, nickname, info) VALUES ('Florian', 'Mistmade03', (SELECT id from player_info WHERE url='https://www.chess.com/member/mistmade03') );

INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/moryzzle');
INSERT INTO "player" (name, nickname, info) VALUES ('Moritz', 'Moryzzle', (SELECT id from player_info WHERE url='https://www.chess.com/member/moryzzle') );

INSERT INTO "player_info" (url) VALUES ('https://www.chess.com/member/pandroit');
INSERT INTO "player" (name, nickname, info) VALUES ('Peter', 'pandroit', (SELECT id from player_info WHERE url='https://www.chess.com/member/pandroit') );

INSERT INTO "season" (year_start, year_end) VALUES (2020, 2020);

INSERT INTO "matchday" (number, season) VALUES (1, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12,  1, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11,  8, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10,  4, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5,  3, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13,  6, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2,  9, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14,  7, 1);

INSERT INTO "matchday" (number, season) VALUES (2, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1, 11, 2);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10, 12, 2);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5,  8, 2);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13,  4, 2);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2,  3, 2);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14,  6, 2);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7,  9, 2);

INSERT INTO "matchday" (number, season) VALUES (3, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10,  1, 3);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5, 11, 3);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13, 12, 3);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2,  8, 3);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14,  4, 3);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7,  3, 3);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9,  6, 3);

INSERT INTO "matchday" (number, season) VALUES (4, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1,  5, 4);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13, 10, 4);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2, 11, 4);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14, 12, 4);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7,  8, 4);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9,  4, 4);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6,  3, 4);

INSERT INTO "matchday" (number, season) VALUES (5, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13,  1, 5);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2,  5, 5);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14, 10, 5);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 11, 5);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 12, 5);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6,  8, 5);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3,  4, 5);

INSERT INTO "matchday" (number, season) VALUES (6, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1,  2, 6);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14, 13, 6);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7,  5, 6);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 10, 6);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6, 11, 6);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3, 12, 6);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4,  8, 6);

INSERT INTO "matchday" (number, season) VALUES (7, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14,  1, 7);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7,  2, 7);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 13, 7);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6,  5, 7);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3, 10, 7);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4, 11, 7);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8, 12, 7);

INSERT INTO "matchday" (number, season) VALUES (8, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1,  7, 8);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 14, 8);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6,  2, 8);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3, 13, 8);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4,  5, 8);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8, 10, 8);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12, 11, 8);

INSERT INTO "matchday" (number, season) VALUES (9, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9,  1, 9);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6,  7, 9);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3, 14, 9);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4,  2, 9);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8, 13, 9);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12,  5, 9);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11, 10, 9);

INSERT INTO "matchday" (number, season) VALUES (10, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1,  6, 10);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3,  9, 10);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4,  7, 10);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8, 14, 10);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12,  2, 10);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11, 13, 10);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10,  5, 10);

INSERT INTO "matchday" (number, season) VALUES (11, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3,  1, 11);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4,  6, 11);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8,  9, 11);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12,  7, 11);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11, 14, 11);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10,  2, 11);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5, 13, 11);

INSERT INTO "matchday" (number, season) VALUES (12, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1,  4, 12);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8,  3, 12);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12,  6, 12);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11,  9, 12);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10,  7, 12);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5, 14, 12);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13,  2, 12);

INSERT INTO "matchday" (number, season) VALUES (13, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8,  1, 13);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12,  4, 13);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11,  3, 13);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10,  6, 13);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5,  9, 13);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13,  7, 13);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2, 14, 13);

INSERT INTO "matchday" (number, season) VALUES (14, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1, 12, 14);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8, 11, 14);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4, 10, 14);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3,  5, 14);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6, 13, 14);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9,  2, 14);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 14, 14);

INSERT INTO "matchday" (number, season) VALUES (15, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11,  1, 15);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12, 10, 15);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8,  5, 15);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4, 13, 15);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3,  2, 15);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6, 14, 15);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9,  7, 15);

INSERT INTO "matchday" (number, season) VALUES (16, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1, 10, 16);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11,  5, 16);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12, 13, 16);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8,  2, 16);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4, 14, 16);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3,  7, 16);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6,  9, 16);

INSERT INTO "matchday" (number, season) VALUES (17, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5,  1, 17);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10, 13, 17);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11,  2, 17);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12, 14, 17);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8,  7, 17);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4,  9, 17);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3,  6, 17);

INSERT INTO "matchday" (number, season) VALUES (18, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1, 13, 18);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5,  2, 18);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10, 14, 18);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11,  7, 18);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12,  9, 18);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8,  6, 18);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4,  3, 18);

INSERT INTO "matchday" (number, season) VALUES (19, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2,  1, 19);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13, 14, 19);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5,  7, 19);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10,  9, 19);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11,  6, 19);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12,  3, 19);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 8,  4, 19);

INSERT INTO "matchday" (number, season) VALUES (20, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1, 14, 20);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2,  7, 20);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13,  9, 20);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5,  6, 20);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10,  3, 20);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11,  4, 20);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (12,  8, 20);

INSERT INTO "matchday" (number, season) VALUES (21, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7,  1, 21);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14,  9, 21);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2,  6, 21);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13,  3, 21);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5,  4, 21);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10,  8, 21);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (11, 12, 21);

INSERT INTO "matchday" (number, season) VALUES (22, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1,  9, 22);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7,  6, 22);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14,  3, 22);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2,  4, 22);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13,  8, 22);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5, 12, 22);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (10, 11, 22);

INSERT INTO "matchday" (number, season) VALUES (23, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6,  1, 23);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9,  3, 23);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7,  4, 23);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14,  8, 23);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2, 12, 23);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13, 11, 23);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 5, 10, 23);

INSERT INTO "matchday" (number, season) VALUES (24, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1,  3, 24);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6,  4, 24);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9,  8, 24);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 12, 24);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14, 11, 24);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2, 10, 24);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (13,  5, 24);

INSERT INTO "matchday" (number, season) VALUES (25, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4,  1, 25);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3,  8, 25);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6, 12, 25);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9, 11, 25);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 10, 25);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14,  5, 25);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 2, 13, 25);

INSERT INTO "matchday" (number, season) VALUES (26, 1);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 1,  8, 26);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 4, 12, 26);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 3, 11, 26);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 6, 10, 26);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 9,  5, 26);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES ( 7, 13, 26);
INSERT INTO "match" ("player1", "player2", "matchday") VALUES (14,  2, 26);

INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8722014513');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=2 AND player2=9 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8722014513'));

INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8723231941');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=2 AND player2=9 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8723231941'));

INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8724907847');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=2 AND player2=9 AND matchday=1), TRUE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8724907847'));

INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8725036665');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=2 AND player2=9 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8725036665'));

INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8725614379');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=2 AND player2=9 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8725614379'));

INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8726184583');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=2 AND player2=9 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8726184583'));


INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8616485043');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=14 AND player2=7 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8616485043'));

INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8618149677');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=14 AND player2=7 AND matchday=1), FALSE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8618149677'));

INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8702757001');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=14 AND player2=7 AND matchday=1), FALSE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8702757001'));

INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8705204521');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=14 AND player2=7 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8705204521'));

INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8705796221');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=14 AND player2=7 AND matchday=1), FALSE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8705796221'));

INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8706438057');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=14 AND player2=7 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8706438057'));


INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8617630129');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=10 AND player2=4 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8617630129'));

INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8618225533');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=10 AND player2=4 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8618225533'));

INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8619306585');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=10 AND player2=4 AND matchday=1), TRUE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8619306585'));

INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8619471075');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=10 AND player2=4 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8619471075'));

INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8620078695');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=10 AND player2=4 AND matchday=1), TRUE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8620078695'));

INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8620568591');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=10 AND player2=4 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8620568591'));

 
INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8504667551');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=13 AND player2=6 AND matchday=1), TRUE, 0, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8504667551'));
 
INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8505882389');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=13 AND player2=6 AND matchday=1), FALSE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8505882389'));
 
INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8507004247');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=13 AND player2=6 AND matchday=1), TRUE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8507004247'));
 
INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8507617133');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=13 AND player2=6 AND matchday=1), FALSE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8507617133'));
 
INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8508203475');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=13 AND player2=6 AND matchday=1), TRUE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8508203475'));
 
INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8508297031');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=13 AND player2=6 AND matchday=1), FALSE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8508297031'));


INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8624735639');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=11 AND player2=8 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8624735639'));

INSERT INTO "game_info" (format, url) VALUES (10, 'https://www.chess.com/live/game/8625353555');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=11 AND player2=8 AND matchday=1), TRUE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8625353555'));

INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8625963087');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=11 AND player2=8 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8625963087'));

INSERT INTO "game_info" (format, url) VALUES (5, 'https://www.chess.com/live/game/8853361491');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=11 AND player2=8 AND matchday=1), TRUE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8853361491'));

INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8853455035');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=11 AND player2=8 AND matchday=1), FALSE, 1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8853455035'));

INSERT INTO "game_info" (format, url) VALUES (3, 'https://www.chess.com/live/game/8854002505');
INSERT INTO "game" (match, player1_is_white, result, info) VALUES ((SELECT id from match WHERE player1=11 AND player2=8 AND matchday=1), TRUE, -1, (SELECT id from game_info WHERE url='https://www.chess.com/live/game/8854002505'));






