Skip to content

Database Schema

BR1K edited this page Jul 16, 2018 · 14 revisions

MVP:

Users

Column Name Data Type Detail
id integer not null, primary key
first_name string not null
last_name string not null
email string not null, unique
password_digest string not null, unique
session_token string not null, unique
created_at date not null
updated_at date not null

Stocks

Column Name Data Type Detail
id integer not null, primary key
symbol string not null

Watchlist Items

Column Name Data Type Detail
id integer not null, primary key
stock_id integer not null, foreign key
user_id integer not null, foreign key

Trades

Column Name Data Type Detail
id integer not null, primary key
stock_id integer not null, foreign key
portfolio_id integer not null, foreign key
num_shares integer not null
price integer not null
type string not null
created_at date not null
updated_at date not null

Portfolio

Column Name Data Type Detail
id integer not null, primary key
user_id integer not null, foreign key

Bonus:

NewsList Items

Column Name Data Type Detail
id integer not null, primary key
company_id integer foreign key
stock_id integer foreign key
title string not null
body string not null

Notifications

Column Name Data Type Detail
id integer not null, primary key
company_id integer foreign key
stock_id integer foreign key
user_id integer foreign key, not null
title string not null
body string not null

Old:

Companies

Column Name Data Type Detail
id integer not null, primary key
name string not null
CEO string not null
market_cap float
industry string
description string

Stocks:

Column Name Data Type Detail
id integer not null, primary key
company_id integer not null, foreign key
user_id integer not null, foreign key
price float not null
day_high float not null
day_low float not null
52wk_high float not null
52wk_low float not null
volume integer
avg_volume integer

Watchlist

Column Name Data Type Detail
id integer not null, primary key
stock_id integer not null, foreign key
user_id integer not null, foreign key
Clone this wiki locally