Schema - rexbodoia/CoinCenter GitHub Wiki

Users

Column Name Data Type Details
id integer not null, primary key, unique
first_name string not null
last_name string not null
email string not null, indexed, unique
img_url string not null
password_digest string not null
session_token string not null, indexed, unique
phone_number string not null, indexed, unique
card_digest string indexed
updated_at datetime not null
created_at datetime not null
  • a user has many balances

Coins

Column Name Data Type Details
id integer not null, primary key, unique
name string not null, unique
ticker_symbol string not null, unique
price float not null
updated_at datetime not null
created_at datetime not null

Transactions

Column Name Data Type Details
id integer not null, primary key, unique
date datetime not null
user_id integer not null, indexed, foreign_key
coin_id integer not null, indexed, foreign_key
amount float not null
updated_at datetime not null
created_at datetime not null
  • the user_id and coin_id point to users and coins respectively
  • each user and each coin have many transactions and each transaction belongs to both a coin and a user
  • like balances, this is essentially a joins table between users and coins, but this also includes dates, to keep track of a history of transactions