Database
The database on this project uses SQLite. This is because of its simplicity and portability.
Table of Contents
Tables
The database contains 2 tables: users
and games
. Each are stored in the same file,
database.db
.
Users
This table contains information about each user, including their name, email, passowrd, etc. Here is an example entry.
id | username | password | session | joindate | |
1 | smitty | billybob@gmail.com | epicpassword | 678281824367599718 | 01/01/1977 |
Here is the create statement.
CREATE TABLE "users" (
"id" INTEGER,
"username" TEXT NOT NULL UNIQUE,
"email" TEXT,
"password" TEXT NOT NULL,
"session" INTEGER,
"joindate" TEXT,
PRIMARY KEY("id")
)
Games
The games table contains all game data. All the data for the game is stored in JSON. Here is an example entry.
id | name | username | data |
1 | poker! | smitty | {"players":["joe","bob"],"buyins":{"joe":19,"bob":12},"cashouts":{"joe":0,"bob":13},"totalPot":18,"totalCashouts":13,"totalBuyins":31,"totalPlayers":2,"buyinsHistory":[{"name":"joe","value":"19","method":"cash"},{"name":"bob","value":"12","method":"zelle"}],"cashoutsHistory":[{"name":"bob","value":"13","method":"cash"}],"totalHistory":[{"type":"join","message":"joe has joined the table!"},{"type":"join","message":"bob has joined the table!"},{"type":"buyin","method":"cash","message":"joe bought in for $19"},{"type":"buyin","method":"zelle","message":"bob bought in for $12"},{"type":"cashout","method":"cash","message":"bob has cashed out for $13"}]} |
Here is the create statement.
CREATE TABLE "games" (
"id" INTEGER,
"name" TEXT UNIQUE,
"username" TEXT NOT NULL,
"data" TEXT NOT NULL,
PRIMARY KEY("id")
)