Skip to content

Database Schema

Tommy Nienchi Chen edited this page Mar 30, 2021 · 5 revisions

Schema for PostgresQL using Sequelize ORM

OPBets Database Schema

Users

Attribute Name Attribute Type Constraints
id int not null, primary key
username string not null, unique, 20 chars or less
email string not null, unique, 255 chars or less
hashedPassword string not null, STRING.BINARY
balance numeric not null
createdAt datetime not null
updatedAt datetime not null

Wagers

Attribute Name Attribute Type Constraints
id int not null, primary key
initial_odds numeric not null
initial_amount numeric not null
current_amount numeric not null
initial_partial_fill_amount numeric not null
liquidityProviderBool Boolean not null
createdAt datetime not null
updatedAt datetime not null
created_by_user_id int foreignkey Users.id

MatchedWagers

Attribute Name Attribute Type Constraints
id int not null, primary key
amount numeric not null
matched_odds numeric not null
eventOverBool Boolean not null
paidOutBool Boolean not null
createdAt datetime not null
updatedAt datetime not null
liquidity_provider_wager_id int foreignkey Wagers.id
liquidity_remover_wager_id int foreignkey Wagers.id
event_prediction_id int foreignkey EventPredictions.id

Events

Attribute Name Attribute Type Constraints
id int not null, primary key
api_id int not null
title String not null
game_api_json TEXT stringified JSON
categories TEXT stringified array
start_time Datetime
end_time Datetime
createdAt datetime not null
updatedAt datetime not null

EventPredictions

Attribute Name Attribute Type Constraints
id int not null, primary key
current_odds numeric
prev_odds numeric
hasEndedBool Boolean not null
createdAt datetime not null
updatedAt datetime not null
event_id int foreignkey Events.id

Clone this wiki locally