<commit_before>-- Table definitions for the tournament project.
--
-- Put your SQL 'create table' statements in this file; also 'create view'
-- statements if you choose to use it.
--
-- You can write comments in this file by starting them with two dashes, like
-- these lines here.

CREATE TABLE players (
  id   SERIAL PRIMARY KEY NOT NULL,
  name TEXT               NOT NULL);

-- VIEW FOR PLAYER PARTICULAR TOURNAMENT AND THEIR STATS
CREATE TABLE tournament_players (
  player_id INTEGER REFERENCES players(id)         NOT NULL,
  tournament_id INTEGER REFERENCES tournaments(id) NOT NULL,
  PRIMARY KEY (player_id, tournament_id));

-- TOURNAMENT : PAIR UP PLAYERS
CREATE TABLE tournaments (
  id   SERIAL PRIMARY KEY NOT NULL,
  name TEXT               NOT NULL);

CREATE TABLE tournament (
  t_id     INTEGER REFERENCES tournaments(id) NOT NULL,
  match    SERIAL                             NOT NULL,
  player_1 INTEGER REFERENCES players(id),
  player_2 INTEGER REFERENCES players(id),
  winner   INTEGER REFERENCES players(id),
  PRIMARY KEY (td, match));

CREATE VIEW tournament_size as
  SELECT tournament_id, count(*) as total_players
  FROM tournament_players
  GROUP BY tournament_id;
<commit_msg>Fixed database definition order so that the view and tournament_players are created the first time.<commit_after>-- Table definitions for the tournament project.
--
-- Put your SQL 'create table' statements in this file; also 'create view'
-- statements if you choose to use it.
--
-- You can write comments in this file by starting them with two dashes, like
-- these lines here.

CREATE TABLE players (
  name TEXT               NOT NULL,
  id   SERIAL PRIMARY KEY NOT NULL);

-- TOURNAMENT : PAIR UP PLAYERS
CREATE TABLE tournaments (
  name TEXT               NOT NULL,
  id   SERIAL PRIMARY KEY NOT NULL);

-- VIEW FOR PLAYER PARTICULAR TOURNAMENT AND THEIR STATS
CREATE TABLE tournament_players (
  player_id INTEGER REFERENCES players(id)         NOT NULL,
  tournament_id INTEGER REFERENCES tournaments(id) NOT NULL,
  PRIMARY KEY (player_id, tournament_id));

CREATE TABLE tournament (
  t_id     INTEGER REFERENCES tournaments(id) NOT NULL,
  match    SERIAL                             NOT NULL,
  player_1 INTEGER REFERENCES players(id),
  player_2 INTEGER REFERENCES players(id),
  winner   INTEGER REFERENCES players(id),
  PRIMARY KEY (t_id, match));

CREATE VIEW tournament_size AS
  SELECT tournament_id, count(*) as total_players
  FROM tournament_players
  GROUP BY tournament_id;

{'fraction_non_alphanumeric': 0.06011146496815287, 'fraction_numerical': 0.0015923566878980893, 'mean_word_length': 3.202341137123746, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3290926', 'n_tokens_mistral': 744, 'n_tokens_neox': 703, 'n_words': 300}