Update backend database specification

This commit is contained in:
Stephen Seo 2022-03-18 17:03:07 +09:00
parent 2f38bf9a0b
commit 495a11b87f

View file

@ -12,8 +12,8 @@ PRAGMA foreign_keys = ON;
// fields should be self explanatory for the players table // fields should be self explanatory for the players table
CREATE TABLE players (id INTEGER PRIMARY KEY NOT NULL, CREATE TABLE players (id INTEGER PRIMARY KEY NOT NULL,
date_added TEXT NOT NULL, date_added TEXT NOT NULL,
game_id INTEGER UNIQUE, game_id INTEGER,
FOREIGN KEY(game_id) REFERENCES games(id)); FOREIGN KEY(game_id) REFERENCES games(id) ON DELETE CASCADE);
// "cyan_player" and "magenta_player" should correspond to an existing entry in // "cyan_player" and "magenta_player" should correspond to an existing entry in
// table "players". // table "players".
@ -23,7 +23,7 @@ CREATE TABLE players (id INTEGER PRIMARY KEY NOT NULL,
// "status" is "0" for cyan's turn, "1" for magenta's turn, "2" for cyan won, // "status" is "0" for cyan's turn, "1" for magenta's turn, "2" for cyan won,
// "3" for magenta won, "4" for draw. // "3" for magenta won, "4" for draw.
CREATE TABLE games (id INTEGER PRIMARY KEY ASC AUTOINCREMENT NOT NULL, CREATE TABLE games (id INTEGER PRIMARY KEY NOT NULL,
cyan_player INTEGER UNIQUE NOT NULL, cyan_player INTEGER UNIQUE NOT NULL,
magenta_player INTEGER UNIQUE NOT NULL, magenta_player INTEGER UNIQUE NOT NULL,
date_changed TEXT NOT NULL, date_changed TEXT NOT NULL,