Skip to content

Database Schema

Steven Inouye edited this page Dec 11, 2018 · 4 revisions

Database Schema

all currency will be stored in cent value and divided by 100 in the front end to get dollar amount

users

column name data type details
id integer not null, primary key
username string not null, indexed, unique
password_digest string not null
session_token string not null, indexed, unique
location string *bonus
created_at datetime not null
updated_at datetime not null

products

column name data type details
id integer not null, primary key
user_id integer not null
sell_by datetime not null
title string not null
location string not null, *bonus
description text
buy_it_now integer *bonus
created_at datetime not null
updated_at datetime not null

user id column represents the owner of the product

bids

column name data type details
id integer not null, primary key
user_id integer not null, indexed
product_id integer not null, indexed
bid_amt integer not null
created_at datetime not null
updated_at datetime not null

joins table for many to many relationship between user and product and adding bid amount information

watches

column name data type details
id integer not null, primary key
user_id integer not null, indexed
product_id integer not null, indexed
created_at datetime not null
updated_at datetime not null

joins table for many to many relationship between product and watcher unique on user_id and product_id

product_categories

column name data type details
id integer not null, primary key
product_id integer not null, indexed
category_id integer not null, indexed
created_at datetime not null
updated_at datetime not null

joins table for many to many relationship between categories and products

categories

column name data type details
id integer not null, primary key
name string not null
created_at datetime not null
updated_at datetime not null
Clone this wiki locally