mazziechai / DonguriGaeru

A Puyo Puyo ranking system
GNU Affero General Public License v3.0
4 stars 0 forks source link

Set up basic database with SQLAlchemy #1

Closed mazziechai closed 3 years ago

mazziechai commented 3 years ago

SQL representation of the database structure


PRAGMA foreign_keys = off;
BEGIN TRANSACTION;

CREATE TABLE guild_settings (
    id     BIGINT PRIMARY KEY ON CONFLICT ROLLBACK,
    prefix TEXT   NOT NULL
                  DEFAULT [;]
);

CREATE TABLE matches (
    id            INTEGER  PRIMARY KEY ON CONFLICT ROLLBACK,
    rating_period INTEGER  REFERENCES rating_periods (id),
    player1       BIGINT   REFERENCES players (id) 
                           NOT NULL,
    player2       BIGINT   REFERENCES players (id) 
                           NOT NULL,
    in_progress   BOOLEAN  NOT NULL,
    completed     BOOLEAN  NOT NULL,
    player1_score INTEGER,
    player2_score INTEGER,
    start_time    DATETIME,
    end_time      DATETIME
);

CREATE TABLE players (
    id               BIGINT PRIMARY KEY ON CONFLICT ROLLBACK,
    display_name     TEXT   UNIQUE ON CONFLICT ROLLBACK,
    rating           DOUBLE NOT NULL,
    rating_deviation DOUBLE NOT NULL,
    volatility       DOUBLE NOT NULL
);

CREATE TABLE rating_periods (
    id         INTEGER  PRIMARY KEY ON CONFLICT ROLLBACK,
    start_time DATETIME NOT NULL
);

COMMIT TRANSACTION;
PRAGMA foreign_keys = on;
amosborne commented 3 years ago

Recent pull request successfully implemented basic SQLAlchemy database with Hiku's World Ranking dataset as an example for future testing and experimentation.